An error occurred while returning data from the AJAX server. onreadystatechange cannot trigger the callback function.

Source: Internet
Author: User
An error occurred while returning data from the AJAX server. onreadystatechange cannot trigger the callback function and input an email in a text tag. when onblur triggers the verification event and checks whether the user exists in the database, the dispear method is used to trigger an onblur event. If the server has received the locally sent data and the verification is successful, the AJAX server fails to send the data back. onreadystatechange cannot trigger the callback function.
Enter an email in a text tag. when onblur triggers the verification event, go to the database to check whether the user already exists. the dispear method is the onblur event trigger method. The verification server has received the data sent locally and the verification is successful, but the echo does not return.
The js code is as follows:
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 ");
// Specify the callback function


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 = "";
*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.