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>
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>