布衣王子

Email:roose2008@gmail.com QQ:79212131

XMLHTTPrequest 错误 等待中

<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Ajax请求测试</title>
<style type="text/css">
 body form{
  margin:100px;
 }
 body input{
  width:200px;
  height:14px;
  margin-top:2px;
  border-width:1px;
  border-style: dashed;
 }
 body #submit{
  border-style:none;
  margin-left:100px;
  margin-top:20px;
  height:20px;
  width:40px;
  background: white;
 }
</style>
<script type="text/javascript">
  var xmlHttp;
  function validate(){
    try{
       // Firefox, Opera 8.0+, Safari
       xmlHttp=new XMLHttpRequest();
      }catch(e){
      // Internet Explorer
       try{ 
        alert("here");
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
         }catch(e){
     try{
             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
             alert("您的浏览器不支持AJAX!");
             return false;
            }
         }   
      }
  }
  
  xmlHttp.onreadystatechange=statusdeal(){
   window.alert("here");
   if(xmlHttp.readyState !=0){
    window.alert(xmlHttp.readyState);
   } 
  }
  xmlHttp.open("GET","test.jsp",true);
  xmlHttp.send("");
    
</script>

</head>
<body>
 <div>
  <form action="test.jsp" name="form" method="get">
   user:<input type='text' name='username' id='user' onblur="validate()" /><br> //错误提示是这里有错,请高手看看
   pass:<input type='password' name='password' onblur="" /><br>
   <input type='submit' name=tijiao  value='提交' id='submit'/>
  </form>
 </div>
 
</body>
</html>

始终无法发出请求,不知道是表单错误还是代码错误.
错误提示是:找不到对象

posted on 2008-12-14 23:19 草包书生 阅读(968) 评论(3)  编辑  收藏

评论

# re: XMLHTTPrequest 错误 等待中 [未登录] 2008-12-15 11:07 草包书生

各位还是帮帮忙吧,兄弟我真的很急呀!  回复  更多评论   

# re: XMLHTTPrequest 错误 等待中 2008-12-15 13:03 appurple

function statusdeal(){
window.alert("here");
if(xmlHttp.readyState !=0){
window.alert(xmlHttp.readyState);
}
}
xmlHttp.onreadystatechange=statusdeal;


首先查文档...  回复  更多评论   

# re: XMLHTTPrequest 错误 等待中 [未登录] 2008-12-15 22:31 草包书生

问题已经解决  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

常用链接

相册

java的相关连接

最新评论