在我的网页中:http://ravi4pk.in/chat
您可以在我的第一个 XMLHttpRequest 中看到我已将 Asnyc 参数设置为 0,即 false。
当我将其设置为 true 时,它不起作用,出了什么问题?
最佳答案
如果您使用异步,则需要使用 onreadystatechange 事件,如下所示:
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
txt = xmlhttp.responseText;
document.getElementById("a").innerHTML = txt;
}
};
关于javascript - 当 Asnyc 设置为 true 时,XMLHttpRequest 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29718361/