open(method,url,async);
send(string);
request.open("GET","get.php",true);
request.send();
request.open("POST","post.php",true);
request.setRequestHeader("Content-type","application/x-www-form-unlencoded");//设置头信息,写在中间
request.send("name=Judy&sex=female");
取得响应:
var request = new XMLHttpRequest();
request.open("GET","get.php",ture);
request.send();
request.onreadystatechange = function(){
if(request.readyState ===4&& request.status===200)
//执行一些事情request.responseText
} }