<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> Asp+ajax Detect if user name is in store </title>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<body>
<script language= "JavaScript" type= "Text/javascript" >
<!--
function Checkusername (userName) {
Building 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 the username to avoid garbled
Xmlhttp.open ("Get", "Checkusername.asp?username=" +escape (userName));
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {
if (xmlhttp.status==200) {
To determine whether a user name exists based on ResponseText
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>