Click to See Complete Forum and Search --> : ie httprequest taking forever


sagel
07-28-2006, 07:53 PM
simplified code is below. ive pulled out just the http request function. i've checked it against a number of tutorials and can't find anything wrong with the code. what it should do is count to 4 for the onreadystatechange. in firefox, it happens as quickly as you'd expect. but in ie, it takes minutes. ive tried it on more than one host, so i dont think it's a server issue. code is running here - feel free to try it.

http://www.textgoeshere.com/test.asp#

any ideas?

thanks,

corey

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
function makePOSTRequest() {
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
updateHint("Cannot create XMLHTTP instance");
return false;
} else {
return http_request;
}
}

function test() {
var updateString='';
http_request=makePOSTRequest();
http_request.onreadystatechange = function() {
alert(http_request.readyState);
if (http_request.readyState == 4) {
if (http_request.status == 200) {
}
}
}
http_request.open('POST', "/test.response.asp", true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", updateString.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(updateString);
}
</script>

</head>

<body>
<a href="#" onclick="test();">test</a>
</body>
</html>

A1ien51
07-28-2006, 09:52 PM
The open statement should come before the onreadystatechange

Should not effect speed.

Eric

sagel
07-28-2006, 10:06 PM
thx. fixed that. and yre right. still not working right.

corey

tilman
07-31-2006, 09:21 AM
Sorry, I don't have a solution either, but pretty much the same problem.
Corey, have you found a solution?

sagel
07-31-2006, 09:38 AM
ive found a script that seems to be working. but ive only created a test page. this AM i started trying to implement it into my app, and it's failing again. *sigh* so no. no solution yet.

corey

sagel
07-31-2006, 10:10 AM
sorry, i should say this - i believe the reason for the ie spin is because the returned document, tho formatted as xml correctly, was not text/xml in the header.

sagel
07-31-2006, 12:33 PM
okay, yes. the code i wound up using came from here:
http://www.xul.fr/en-xml-ajax.html
(the live samples, not the code described). and then making sure my requested documents had a doc type of: text/xml worked. woohoo!

corey

tilman
08-01-2006, 02:14 AM
Corey, thanks a lot for the hint. This gave me the right idea. After I sent a POST to the server, the PHP app there didn't really send anything back, and the response header only had a HTTP/1.x 200 OK, but nothing else. This is enough for Firefox to set the readyState to 4, but not for IE!

netbuddy
08-01-2006, 08:19 AM
I would look at http://www.jibbering.com/2002/4/httprequest.html