AJAX Server loopback data failed onreadystatechange cannot trigger callback function

Source: Internet
Author: User
AJAX Server loopback data failed onreadystatechange cannot trigger callback function
Enter an e-mail message in a text label that triggers a validation event when onblur, to the database to verify that the user already exists, where the Dispear method is the method that is triggered by the onblur event. Verified the server has received the data sent locally and verified the success, but Echo does not go back.
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");
Specifying a 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.