<html>
<head>
<title>Ajax講解 - www.111cn.net - </title>
<script type="text/javascript">
function createXmlHttp(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function sendAjax(strUrl){
createXmlHttp();
xmlHttp.open("GET",strUrl,true);
xmlHttp.onreadystatechange=process;
xmlHttp.send(null);
}
function process(){
if (xmlHttp.readyState==4){
if(xmlHttp.status==200){
alert(xmlHttp.responseText);
}
}
}
function call_back(){
var love=document.getElementById("love").value;
var url="me.php?love="+love;
sendAjax(url);
}
</script>
</head>
<body>
<center>
<form name="f1">
愛好:<input type="text" name="love" id="love" />
<input type="button" value="提交" onClick="call_back()" />
</form>
</center>
</body>
</html>
上面主要是建立ajax下面用php
<?php
sleep(1);
$love=$_GET["love"];
echo "You love : ".$love;
?>