/**
* Created by luby on 2015/8/8.
*/
var xmlHttp; //创建ajax对象
function xmlHttpRequest(){
if(window.ActiveXObject){ //IE浏览器
xmlHttp = new ActiveXObject(‘Microsoft.XMLHTTP‘);
}else if(window.XMLHttpRequest){ //火狐等浏览器
xmlHttp = new XMLHttpRequest();
}
}
function dianji(){ //js触发对象
xmlHttpRequest(); //引用ajax对象
var username = document.myform.username.value; //获取用户数据
xmlHttp.open("GET","for.php?id="+username,true); //打开连接
xmlHttp.onreadystatechange = luyi; //触发对象
xmlHttp.send(null); //发送请求
}
function luyi(){
if(xmlHttp.readyState==1){
document.getElementById(‘xianshi‘).innerHTML = "loading...";
}
if(xmlHttp.readyState==4) {
if(xmlHttp.status==200){
var result = xmlHttp.responseText;
document.getElementById(‘xianshi‘).innerHTML = result; //返回值
}
}
}