[英]“Operation aborted” error message when loading a webpage in Internet Explorer
[英]Internet Explorer error message “The operation was timed out”
我有一段代码可以在chrome和firefox中使用,但不能在Internet Explorer中使用。 我不知道是什么原因造成的。 我从Internet Explorer收到操作超时消息"Message: The operation was timed out."
这是我正在使用的ajax函数,它来自w3schools,所以我知道这是正确的。
function ajax() {
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
alert(xmlhttp);
return xmlhttp;
}
这是被卡住的代码。 错误消息在"ajaxRequest.send(postdata);"
。
function edit(){
var ajaxRequest = ajax();
var postdata = "data=" + document.getElementById("id1").value + "<|>" + document.getElementById("id2").value + "<|>" + document.getElementById("id3").value;
ajaxRequest.onreadystatechange = function(){
var ajaxDisplay = document.getElementById('ajaxDiv');
if(ajaxRequest.readyState == 4 && ajaxRequest.status==200){
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
alert(postdata);
ajaxRequest.open("POST","confirmPage.php",false);
ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajaxRequest.send(postdata);
alert("Finished");
}
所有其他页面在Internet Explorer中都使用相同的代码,但不适用于此特定页面。 我似乎无法弄清楚为什么。 此页面适用于chrome和Firefox,但不适用于Internet Explorer。 它永远不会转到“完成”。 我正在使用IE 8。
当您需要同步行为时,请尝试以下操作:
ajaxRequest.open("POST", "confirmPage.php", false);
ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajaxRequest.send(postdata);
if (ajaxRequest.status === 200) {
document.getElementById('ajaxDiv').innerHTML = ajaxRequest.responseText;
}
alert("Finished");
您不需要onreadystatechange
因为请求是同步的。
部分答案:
我解决了这个问题。 不是javascript和/或ajax。 IE无法处理查询中的大量结果,因此超时。 这是一个非常晦涩的错误,因为我一直认为这与ajax函数而不是php文件有关。
结果集不是很大。 有5个不同的查询。 每个记录大约有5-50K(我不打印所有记录,只是查询)。 在设置大量结果后超时。
为了进行测试,我使用简单的SELECT *
查询创建了一个测试页,它只能处理2-3个查询。 如果不止于此,它将超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.