Index. asp
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> new document </title>
<Meta name = "generator" content = "editplus">
<Meta name = "author" content = "">
<Meta name = "keywords" content = "">
<Meta name = "Description" content = "">
<Script language = JavaScript>
VaR XMLHTTP = false;
Function createxmlhttprequest ()
{
XMLHTTP = false;
Try
{
XMLHTTP = new XMLHttpRequest ();
}
Catch (trymicrosoft)
{
Try
{
XMLHTTP = new activexobject ("msxml2.xmlhttp ");
}
Catch (othermicrosoft)
{
Try
{
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
}
Catch (failed)
{
Return false;
}
}
}
If (! XMLHTTP)
{
Return false;
}
}
//
Function checkusernameinput ()
{
VaR UN = Document. getelementbyid ('username'). Value
VaR dispobj = Document. getelementbyid ("checkresult ");
Createxmlhttprequest ();
Dispobj. innerhtml = '& nbsp; query in progress. Please wait...'; // It is better to add this sentence if the query takes a long time.
XMLHTTP. Open ("get", "checkusername. asp? Keyword = "+ escape (un) +" ", true );
// Access checkusername. asp and pass a parameter to the page
// The first parameter can be post or get, which is a form submission method.
XMLHTTP. onreadystatechange = function ()
{
If (4 = XMLHTTP. readystate)
{
If (200 = XMLHTTP. Status)
{
Dispobj. innerhtml = XMLHTTP. responsetext;
}
}
} XMLHTTP. Send ();
}
</SCRIPT>
</Head>
<Body>
<Form name = "form1" method = "get">
<Input name = "username" type = text>
<Input type = "button" value = "check" onclick = "checkusernameinput ()"> & nbsp;
<Font color = Red style = "font-size = 9pt" id = "checkresult"> </font>
</Form>
</Body>
</Html>
Checkusername. asp
<%
Keyword = request. querystring ("keyword ")
Response. write keyword
'This example only shows the content entered by the user. If you want to verify the code, add it yourself.
%>