[英]Internet Explorer error message “The operation was timed out”
I have a piece of code that works in chrome and firefox but not in internet explorer. 我有一段代码可以在chrome和firefox中使用,但不能在Internet Explorer中使用。 I can't figure out what that actual cause is. 我不知道是什么原因造成的。 I get a operation timeout message from internet explorer "Message: The operation was timed out."
我从Internet Explorer收到操作超时消息"Message: The operation was timed out."
This is the ajax function I am using, it's from w3schools so I know this is correct. 这是我正在使用的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;
}
This is the code that's getting stuck on. 这是被卡住的代码。 The error message is in "ajaxRequest.send(postdata);"
错误消息在"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");
}
All the other pages work with the same code in internet explorer but not this particular page. 所有其他页面在Internet Explorer中都使用相同的代码,但不适用于此特定页面。 I can't seem to figure to out why. 我似乎无法弄清楚为什么。 This page works in chrome and firefox but not in internet explorer. 此页面适用于chrome和Firefox,但不适用于Internet Explorer。 It never goes to "Finished". 它永远不会转到“完成”。 I am using IE 8. 我正在使用IE 8。
As you require synchronous behaviour try the following: 当您需要同步行为时,请尝试以下操作:
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");
You don't need the onreadystatechange
as the request is synchronous. 您不需要onreadystatechange
因为请求是同步的。
Partial answer: 部分答案:
I figured out the problem. 我解决了这个问题。 It's not javascript and/or ajax. 不是javascript和/或ajax。 IE can't handle a large number of results in queries so it times out. IE无法处理查询中的大量结果,因此超时。 It's a very obscure error as I was thinking it's something to do with the ajax functions rather than the php file. 这是一个非常晦涩的错误,因为我一直认为这与ajax函数而不是php文件有关。
The result set is not huge. 结果集不是很大。 There are 5 different queries. 有5个不同的查询。 Each one with about 5-50K records(I am not printing all of them, just querying). 每个记录大约有5-50K(我不打印所有记录,只是查询)。 It times out after a large result set. 在设置大量结果后超时。
To test I created a test page with simple SELECT *
queries and it can handle only 2-3 queries. 为了进行测试,我使用简单的SELECT *
查询创建了一个测试页,它只能处理2-3个查询。 If it's more than that it times out. 如果不止于此,它将超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.