let xhr = new XMLHttpRequest()
console.log(xhr.readyState);
xhr.open('get', 'http://www.baidu.com')
console.log(xhr.readyState);
xhr.send()
console.log(xhr.readyState);
// onreadystatechange 监听 readyState 的变化 状态 4 为请求已完成
xhr.onreadystatechange = function () {
console.log(xhr.readyState);
if (xhr.readyState == 4 && xhr.status == 200) {
console.log('请求成功');
}
}