var xhr;
if (window.XMLHttpRequest){
xhr=new XMLHttpRequest();
}else{
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
console.log("状态A "+xhr.readyState);
// 2.配置信息
// var url="Ajax.php?username="+username+"&password="+password;
// xhr.open('get',url,true);
var url='Ajax.php';
xhr.open('post',url,true);
xhr.setRequestHeader('Content-type',"application/x-www-form-urlencoded");
console.log("状态B "+xhr.readyState);
// 3.发送请求
// xhr.send();
xhr.send("username="+username+"&password="+password);
console.log("状态C"+xhr.readyState);
// 4.获取信息
xhr.onreadystatechange=function(){
console.log("状态D"+xhr.readyState);
if (xhr.readyState==4 && xhr.status==200){
var div=document.getElementById("div");
div.innerHTML=xhr.responseText;
}
xhr=new XMLHttpRequest();
}else{
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
console.log("状态A "+xhr.readyState);
// 2.配置信息
// var url="Ajax.php?username="+username+"&password="+password;
// xhr.open('get',url,true);
var url='Ajax.php';
xhr.open('post',url,true);
xhr.setRequestHeader('Content-type',"application/x-www-form-urlencoded");
console.log("状态B "+xhr.readyState);
// 3.发送请求
// xhr.send();
xhr.send("username="+username+"&password="+password);
console.log("状态C"+xhr.readyState);
// 4.获取信息
xhr.onreadystatechange=function(){
console.log("状态D"+xhr.readyState);
if (xhr.readyState==4 && xhr.status==200){
var div=document.getElementById("div");
div.innerHTML=xhr.responseText;
}
}

1119

被折叠的 条评论
为什么被折叠?



