1.post方法中,数据放在send()方法中,作为参数传递
2.需要设置请求头,用来指明编码方式,发送的数据类型
3.post方式不会出现中文乱码和浏览器缓存问题
var ajax=null; try { ajax=new XMLHttpRequest() }catch(e) { ajax=new ActiveXObject("Microsoft.XMLHTTP") } ajax.open("post","a.php",true) ajax.setRequestHeader("content-type","application/x-www-form-urlencoded") ajax.send("name=张三&age=20") ajax.onreadystatechange=function(){ if(ajax.readyState==4){ if(ajax.status==200){ console.log(ajax.responseText) } }else{ console.log(ajax.status) } }