9.25 Ajax 基本上搞定,今天的收获

除去过去所学会的,今天又有了很多的收获,比起以前,这次写ajax容易多了,也很轻松~!

 

 

 

 var xmlHttpRequest;

 function creatXmlHttp(){
 if(window.ActiveXObject)
     {
      xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
     }else{
      xmlHttpRequest=new XMLHttpRequest();
     }    
   
  }
----------------------- 
 

function checkuser(){
creatXmlHttp();
var name=document.all("user").value;

xmlHttpRequest.onreadystatechange=function(){
        if (xmlHttpRequest.readyState==4){
   
            if (xmlHttpRequest.status==200){
                result=xmlHttpRequest.responseText;
                  if (result=="true"){
     document.getElementById("right").style.display="block";
     document.getElementById("wrong").style.display="none";
   }else{
   document.getElementById("right").style.display="none";
     document.getElementById("wrong").style.display="block";
   }
    
                           
            }else{
                window.status="验证码检验失败,请联系管理员!";               
            }
        }else{
            window.status="正在进行验证码检验...";       
        }   
    }

 

   xmlHttpRequest.open("post","/ajaxjson/ajax.do?name="+name,true);//true 异步 false 同步
   xmlHttpRequest.send();
------------------ 早在一起,不喜欢按规范写,有时候不用这个xmlHttpRequest.onreadystatechange,喜欢直接在

xmlHttpRequest.send(); 后面直接写 

result=xmlHttpRequest.responseText; 以前没有发现什么错误。可是今天调试了老半天,都说我网页错误,一查总是这个 result=xmlHttpRequest.responseText 错误~! 好无奈了~!

----------------学到~--以前怎么不出同步问题呢??  不过还是按规范吧。毕竟这个方法自有其妙用------受教--


}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值