<!DOCTYPE HTML PUBLIC "//WC//DTD HTML Transitional//EN">
<html>
<head>
<title> asp+ajax检测用户名是否在存</title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!
function checkUserName(userName){
//建立跨浏览器的XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp= new ActiveXObject(MsxmlXMLHTTP);
}catch(e){
try{
xmlhttp= new ActiveXObject(MicrosoftXMLHTTP);
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}
//创建请求并使用escape对userName编码以避免乱码
xml("get""checkUserNameasp?userName="+escape(userName));
xml(){
if(xml{
if(xml{
//根据responseText判断用户名是否存在
if(xml("对不起该用户名以存在!");
else alert("恭喜!该用户名未被注册!");
}else{
alert("网络失败");
}
}
}
xml(null);
}
//>
</script>
</body>
</html>