本例一共需3个文件
![](https://www.ningmop.com/wp-content/uploads/c140925/1411641T9240-1F40.jpg)
Ajax.js
var xmlHttp;
//实例化过程
function S_xmlhttprequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function funphp100(name){
//获取form内容
//http://www.ruoshuiyx.com 沈阳网站建设
var f=document.myform.user.value;
//引用实例化过程
S_xmlhttprequest();
//打开请求
xmlHttp.open("GET","index.php?id="+f,true);
//准备就绪执行
xmlHttp.onreadystatechange=byphp;
xmlHttp.send(null);
}
function byphp() {
if(xmlHttp.readyState== 1) {
document.getElementById('php100').innerHTML = "
![](http://www.dedecms.com/knowledge/program/php/2013/0529/file:/C:/Program%20Files/%E4%B8%80%E9%94%AE%E6%8E%92%E7%89%88/lib/loading.gif)
}
if(xmlHttp.readyState== 4 ){
if(xmlHttp.status == 200) {
var byphp100 = xmlHttp.responseText;
document.getElementById('php100').innerHTML = byphp100;
}
}
}
For.php
用户名//http://www.ruoshuiyx.com 沈阳网站建设:
Index.php
if($id=$_REQUEST[id])
{
//for ($i=1;$i<3;$i++)
//{
// echo$id;
// sleep(1);//
/