2.发起对服务器的请求:
1)首先发送的是get请求:
var ah= new XMLHttpRequest();ah.open("get","url");
ah.send(null);
ah.onreadystatechange=function(){
if(ah.readyState==4&&ah.status==200){
//成功,获取返回的result
ah.responsteText.
或者
var xmls = ah.responsteXML.
}
}
2)第二个是post请求
var ah = new XMLHttpResquest();
ah.open("post","url");
ah.setRequestHeader("content-type","application/x-www-form-urlencoded");
ah.send("xxx=111&xxx=222后面要追加的信息");//当xxx=“中文”需转码:“xxx =”+encodeURIComponent(value) ;