// 1、 if (window.XMLHttpRequest) { var xhr = new XMLHttpRequest(); console.log(xhr); console.log(xhr.constructor); } else { // IE6- var xhr = new ActiveXObject(); } // 2、 // open("请求的方式","请求的地址",是否异步) ---后端人员给提供的 // true 异步 false 同步 默认是异步 xhr.open("GET", "ajax_info.txt", true); // 3、 xhr.send(); // 4、 xhr.onreadystatechange = function () { console.log(xhr); console.log(xhr.readyState);//4 console.log(xhr.status);//200 // 5、 if (xhr.readyState == 4 && xhr.status == 200) { // 6、 console.log(xhr.response); // 7、 document.getElementById("Box").innerText = xhr.response; } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。