Ajax test User Name tutorial a

Source: Internet
Author: User

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>

Related Article

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.