Ajax detection Username This article is about a Chan ASP Ajax detection username and AJAX authentication username and PHP ajax,asp Ajax, what is Ajax and so on, and for example. Let's take the example of ASP.
The first step: Create a database Ajax.mdb with access in office, and then create a datasheet user with UserID and userpwd two fields, good database is over.
The second step: the user input interface is as follows:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>ajax file </title>
<script language= "JavaScript" type= "Text/javascript" >
var xmlHttp = false;
if (window. ActiveXObject) {
xmlHttp = new ActiveXObject ("Msxml2.xmlhttp");
} else {
XmlHttp = new XMLHttpRequest ();
}
if (!xmlhttp) {alert ("hehe, your system does not support")}
Function CheckUser ()
{
var url = "Act.asp?m Ydo=checkuser&userid= "+document.xp.userid.value
Xmlhttp.open ( "Get", url, True);
xmlhttp.onreadystatechange = checkpage;//You can call the CheckPage () function directly
& nbsp; xmlhttp.send (NULL);
}
function CheckPage () {
if (xmlhttp.readystate = = 0) {text.innerhtml= "querying data";}
if (xmlhttp.readystate = = 1) {text.innerhtml= "initializing data";}
if (xmlhttp.readystate = = 2) {text.innerhtml= "sending data";}
if (xmlhttp.readystate = = 3) {text.innerhtml= "data transfer";}
if (xmlhttp.readystate = 4)//4 is ready to complete
{
var Checkresult=xmlhttp.responsetext; Get the data to process the page
Text.innerhtml= Checkresult;
}
}
</script>
<body>
<form name= "XP" >
<input type= "text" name= "UserId" onblur= "CheckUser ()" >
<input type= "Submit" name= "Submission" value= "submitted" >
</form><div id= "Text" ></div>
</body>