日期:2014-05-16 浏览次数:20987 次
<html>
<head>
<link rel="stylesheet" href="/css/css.css" type="text/csss">
<meta http-equiv="content-type" content="text/html; charest=utf-8"/>
<script type="text/javascript" >
function getXmlHttpObject(){
var xmlHttpRequest;
if(window.ActiveXobject){
xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
else{
xmlHttpRequest=new XMLHttpRequest();
}
return xmlHttpRequest;
}
var myXmlHttpRequest=getXmlHttpObject();
function checkname(){
if(myXmlHttpRequest){
var url="/ajax/p.php?username="+$("username").value;
myXmlHttpRequest.open("get",url,true);
myXmlHttpRequest.onreadystatechange=chuli;
myXmlHttpRequest.send(null);
}
else{
alert("失败");
}
}
function chuli(){
alert("处理"+myXmlHttpRequest.readyState);
//if(myXmlHttpRequest.readyState==4){
//alert("返回"+myXmlHttpRequest.responseText);
//}
}
function $(id){
return document.getElementById(id);
}
</script>
</head>
<h1>用户注册</h1>
<form action="" method="post">
<table width="600" height="300">
<tr> <td>账号</td> <td> <input type="text" name="username1" id="username"><input type="submit" onclick="checkname();" value="验证"/></td> </tr>
<tr> <td>密码</td> <td> <input type="password" ></td> </tr>
<tr> <td>重复输入密码</td> <td> <input type="password" ></td> </tr>
<tr> <td>电子邮箱</td> <td> <input type="text" ></td> </tr>
<tr> <td><input type="submit" value="提交"/></td> <td> <input type="reset" value="重置"/> </td> </tr>
</table>
</form>
</html>
var url="/ajax/p.php?username="+$("username").value+'&_dc='+new Date().getTime();
myXmlHttpRequest.onreadystatechange=chuli;
myXmlHttpRequest.open("get",url,true);
//myXmlHttpRequest.onreadystatechange=chuli;