Copy codeThe Code is as follows:
<Script type = "text/javascript"> <! --
Var request = false;
Try {
Request = new XMLHttpRequest ();
} Catch (trymicrosoft ){
Try {
Request = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (othermicrosoft ){
Try {
Request = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (failed ){
Request = false;
}
}
}
If (! Request) alert ("Error initializing XMLHttpRequest! ");
// Obtain information
Function GetInfo (){
Var url = "test. aspx? UserName = "+ document. getElementById (" txtName "). value;
Request. open ("GET", url, true );
Request. onreadystatechange = updatePageTime;
Request. send (null );
}
// Update page
Function updatePageTime (){
If (request. readyState = 4 ){
If (request. status = 200 ){
Var response = request. responseText;
Document. getElementById ("txtLoginName"). value = response;
} Else if (request. status = 404 ){
Alert ("Requested URL is not found .");
} Else if (request. status = 403 ){
Alert ("Access denied .");
} Else
Alert ("status is" + request. status );
}
}
// --> </Script>
<Form id = "form1" runat = "server">
<Input id = "txtName" onchange = "GetInfo ()" type = "text"/>
<Input id = "txtLoginName" type = "text"/>
</Form>