Ajax No Refresh
Copy Code code as follows:
var xmlHttp;
UName ()//user name loses focus
{
if (all.uname.== "")
{
All.l1.innerhtml= "cannot be empty!" ";
SetTimeout ("Close (1)", 1500);
Return
}
Else
{
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
Xmlhttp.onreadystatechange=deal; callback function
var url= "ajax.aspx?user= '" +all.uname.+ ""; The page that will jump to the test user name
Xmlhttp.open ("Get", url,true); Submit the form to the URL in Get mode, and start a step process
Xmlhttp.send (NULL); Send
}
}
Deal ()
{
Alert (xmlhttp.readystate+ "__" +xmlhttp.status);
if (xmlhttp.readystate!=4)
{return;}
if (xmlhttp.status!=200)//equal to 500 is an SQL statement or database error
{return;}
//
var num = Xmlhttp.responsetext; Information sent by the receiving server
alert (num);
All.l1.innertext= "";
if (num>0)
{
all.l1.innertext= "The secondary username is already in use!" ";
}
Else
{
all.l1.innertext= "√";
}
}