在w3school里看的,也是自己弄的第一个,算是做个笔记吧,留给自己看
html

Code
<html>
<body>
<script type="text/javascript">
var xmlHttp;
function checkExist()
{
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new xmlHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.xmlHttp");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.xmlHttp");
}
catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange= Exist;
xmlHttp.open("GET","check.asp?uname=" + document.getElementById("uname").value,true);
xmlHttp.send(null);
}
function Exist()
{
if(xmlHttp.readyState==4)
{
document.getElementById("time2").value=xmlHttp.responseText;
}
}
</script>
<form name="myForm">
用户名: <input type="text" id="uname" onblur="checkExist()" />
是否可用 <input type="text" id="time2"/>
</form>
</body>
</html>
check.asp
<%
'response.expires=-1
uname = request.Querystring("uname")
if uname = "aa" then
response.write("Exist use other")
else
response.write("avaiable")
end if
%>