正如我在标题中所写,xmlhttprequest 不会发送请求。该代码非常基本,我不知道为什么它不应该工作。这里是:
window.onload = function() {
xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'http://www.google.com' , true);
xmlhttp.send(null);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.write(xmlhttp.responseText);
}
}
if (xmlhttp.readyState!=4) {
document.write(xmlhttp.readyState);
}
}
它只是在文档中写入“1”。我错过了什么明显的东西吗?