Home > Web Front-end > JS Tutorial > body text

Ajax submission form to achieve web page refresh registration example_Basic knowledge

WBOY
Release: 2016-05-16 16:49:18
Original
1690 people have browsed it

Ajax no refresh

Copy code The code is as follows:

var xmlHttp;
uName() //User When 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. "'"; //Will jump to the page where the user name is detected
xmlHttp.open("get",url,true ); //Submit the form to the url using get mode; and start one-step processing
xmlHttp.send(null); //Send
}
}
deal()
{
//alert(xmlHttp.readystate "__" xmlHttp.status);
if(xmlHttp.readystate!=4)
{return; }

if(xmlHttp.status!=200) //When equal to 500, it is an error in the sql statement or database
{return;}
//

var num = xmlHttp.responseText; //Receive information sent by the server
//alert(num);
all.l1.innerText="";
if(num>0)
{
all.l1.innerText="This username has been used!";
}
else
{
all.l1.innerText="√";
}

}

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!