javascript异步提交问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 01:35:42
我刚学javascript不知道怎么才能异步提交。比如不用刷新页面就能判断用户名是否是重复的
请大家把代码粘出来,加上注释 谢谢大家了
如果有可以学习的网页粘出来也可 谢谢大家了啊
MS_Frank 你能把注释加上么?谢谢啊~~~我真的看不明白啊

客户端:新建一个任意名字.html
<html>
<head>
<script type="text/javascript">
function test(name){
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("GET","checkUser.asp?name="+name,true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText="yes") alert("可以用");
else alert("用户名已经存在!");
}
}
}
xmlHttp.send(null);
}
</script>
</head>
<body>
<input type="button" value="Ajax" onclick="test('aaa');"/>
</body>
</html>
服务器端:新建一个checkUser.asp
<%
'为了简化,我不读取数据库
if(Request.QueryString("name")="aaa")
Response.Write("yes");
%>

我以前写的一个异步