<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttP = new XMLHttpRequest();
}
}
function doGet(name){
createXMLHttpRequest();
if(name = document.getElementById('name').value){
xmlHttp.open("get","date.php?name="+name,true);
xmlHttp.onreadystatechange = byname;
xmlHttp.send(null);
}
}
function byname(){
if(xmlHttp.readyState == 1){
document.getElementById('span').innerHTML = "<font color='red'>loading.....</font>";
}
if(xmlHttp.readyState ==4){
if(xmlHttp.status ==200){
document.getElementById('span').innerHTML = xmlHttp.responseText;
}
}
}
</script>
<title>無標題文檔</title>
</head>
<body>
<form action="" name="forms" method="post">
<input type="text" name="name" id="name"/><span id="span"></span>
<br />
<input type="button" value="click" name="button" />
</form>
</body>
</html>
date.php
<?
/*-- 獲取值,並輸出--*/
sleep(1);
$name = $_REQUEST['name'];
echo $name;
?>