<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"
<title> asp+ Ajax detects whether the username is stored </title>
<meta name= "generator" content= "EditPlus"
<meta name= "Author" content= ""
<meta name= "Keywords" content= ""
<meta name= "Description" "
<body>
<script language= "JavaScript" type= "Text/javascript"
<!--
function Checkusername (userName) {
//to establish a XMLHttpRequest object across browsers
var xmlhttp;
try{
xmlhttp= new ActiveXObject (' msxml2.xmlhttp ');
}catch (e) {
try{
xmlhttp= new ActiveXObject (' microsoft.xmlhttp ');
} catch (e) {
try{
xmlhttp= new XMLHttpRequest ();
}catch (e) {}
}
//Create the request and use escape to encode username to avoid garbled
xmlhttp.open ("Get", "checkusername.asp?"). Username= "+escape (userName));
xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {
if ( xmlhttp.status==200) {
//ResponseText to determine if the user name exists
if ( xmlhttp.responsetext== "1") alert ("Sorry, the username exists!") ");
Else alert ("Congratulations!)" The user name is not registered! ");
}else{
alert ("Network failure。 ");
}
}
}
xmlhttp.send (NULL);
}
//-->
</script>
</body>