我正在编写一个使用 Comet/长轮询 来使网页保持更新的 AJAX 网络应用程序,在 Chrome 中,我发现它会将页面视为始终在加载中(标签的图标一直旋转)。
我原本以为这对于 Google Chrome + Ajax 是正常行为,因为即使 Google Wave 也有这种行为。
今天我发现 Google Wave 不再让加载图标旋转了,有人知道他们是如何解决这个问题的吗?
这是我的 Ajax 调用代码:
var xmlHttpReq = false;
// Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open('GET', myURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
updatePage(xmlHttpReq.responseText);
}
}
xmlHttpReq.send(null);