<?php
/*
* 制作日期 2008-11-25
*
* QQ114009323 MAIL:cyr11@163.com 下雨天
*
*转载保存哦
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AJAX</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<script type="text/javascript">
var xmlHttp=false;
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp=false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp=new XMLHttpRequest();
}
function CallServer()
{
var UserID=document.getElementById("UserID").value;
if (UserID!="")
{
var url ="Request.php?UserID="+UserID;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=UpdateData;
xmlHttp.send(null);
}else
{
alert("请您填写用户名!");
}
}
function UpdateData()
{
if(xmlHttp.readyState<4)
{
span.innerHTML="loading...";
}
if(xmlHttp.readyState==4)
{
document.getElementById("span").innerHTML=xmlHttp.responseText;
}
}
</script>
用户名: <input type="text" name="UserID" id="UserID" onchange="CallServer()" />
<span id="span"></span>
</body>
</html>