① 创建XMLHTTPRequest对象
var xhr = new XMLHttpRequest();

④//onreadystatechange事件: readyState的值每次发生变化都会触发该事件。
xhr.onreadystatechange = function(){
if (xhr.readyState==4 && xhr.status == 200){

//如果等于4的话,说明已经完全接收到返回数据,并且可以在浏览器中使用了,
//以字符串形式接收后端的返回值
//xhr.responseText是接收到的数据

alert('xhr.responseText')//PHP程序最终会被解析为一段字符串,responseText接收的就是这段字符串 

  }
}
②准备ajax请求
xhr.open('get','路径');
③发送ajax请求
xhr.send(null);