AJAX 服务器回送数据失败 onreadystatechange没法触发回调函数

WBOY
Release: 2016-06-13 11:13:03
Original
695 people have browsed it

AJAX 服务器回送数据失败 onreadystatechange无法触发回调函数
在一个文本标签中输入电子邮件,当onblur时触发验证事件,到数据库检验是否已经存在该用户,其中dispear方法即为onblur事件触发的方法。已经验证服务器已经收到本地发送的数据并且验证成功,但是echo不回去。
js代码如下:
var myXmlHttpRequest;
function getXmlHttpObject(){
   var xmlHttpRequest;
   try{
     xmlHttpRequest=new XMLHttpRequest();
     
   }
catch(e){
   try{
      xmlHttpRequest=new ActiveXObject("Msxml2.HMLHTTP");
      
   }
   catch(e){
      xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
      
   }
 }
   return xmlHttpRequest;
 }




function isExist(email){

    myXmlHttpRequest=getXmlHttpObject();
    if(myXmlHttpRequest){
     alert("hello"+email);
    
    var url="/renren/register_legal_Process.php";
    var data="email="+email;
    myXmlHttpRequest.open("post",url,true);
    myXmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    // 指定回调函数
    
    
   myXmlHttpRequest。onreadystatechange=deal;
    myXmlHttpRequest.send(data);
    
    //alert(myXmlHttpRequest.readyState);
    }
}
function deal(){

alert('hello');
    if(myXmlHttpRequest.readyState==4){
    
     var isExist=myXmlHttpRequest.responseText;
    
     if(isExist=="exist"){
     $("focus1").style.display="none";
     $("wrong1").style.display="none";
     $("duihao").style.display="none";
     $('wrong5').style.display="block";
     }else if(isExist=="notexist"){
     $("focus1").style.display="none";
     $("wrong1").style.display="none";
     $("wrong5").style.display="none";
     $("duihao").style.display="block";     
     }
    
    
    } 
   
}
function $(id){
  return document.getElementById(id);
}  
function disappear(ref1,ref2,ref3,ref4){
    var app=$(ref1);
 var tmp1=$(ref2);
 var tmp2=$(ref3);
 var tmp3=$(ref4);
 var str=tmp1.value;
 var reg=/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;

         if(!reg.test(str))
{
     tmp3.style.display="none";
 app.style.display="none";
 $("wrong5").style.display="none";
 tmp2.style.display="";
}
else
{   
/*
 * tmp2.style.display="none"; app.style.display="none";
 * tmp3.style.display="";
 */

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template