Ajax submission form implementation web page with no refresh registration example
- 2020-03-30 02:53:59
- OfStack
Ajax no refresh
var xmlHttp;
uName() //When the username loses focus & NBSP;
{
if(all.uname.=="")
{
all.l1.innerHTML=" Can't be empty! ";
setTimeout("close(1)",1500);
return;
}
else
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange=deal; //Callback function & NBSP;
var url="aJax.aspx?user='"+all.uname.+"'"; //You will jump to the page that detects the username & NBSP;
xmlHttp.open("get",url,true); //Submit the form to the url in get mode; And start a one-step process & NBSP;
xmlHttp.send(null); //Send
}
}
deal()
{
//alert(xmlHttp.readystate+"__"+xmlHttp.status);
if(xmlHttp.readystate!=4)
{return; }
if(xmlHttp.status!=200) //Equals 500 is an SQL statement or database error & NBSP;
{return;}
//
var num = xmlHttp.responseText; //Receive the message sent by the server & NBSP;
//alert(num);
all.l1.innerText="";
if(num>0)
{
all.l1.innerText=" The secondary username has been used! ";
}
else
{
all.l1.innerText=" Square root ";
}
}