M
marss
I faced to a strange problem I couldn't solve myself.
I use XMLHttpRequest in order to periodically ask server for some
data. I use code I have used many times before (but not in a loop).
It works fine in Firefox but not in IE .
In IE it executes only time, then "send" method executes as it should
but method attached to "onreadystatechange" never called.
I mean
.... send ...
.... an event handler for onreadystatechange ...
.... send ...
.... send ...
.... send ...
.... send ...
Could anybody give me a suggestion about reasons of that behaviour?
Regards, Mykola
http://marss.co.ua
Below is a snippet to illustrate the situation.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>String Build Performance Tester</title>
</head>
<body>
<script type="text/javascript">
function InitializeXMLHttpRequest(req)
{
if (req != null)
req.abort();
if (typeof XMLHttpRequest != "undefined")
req = new XMLHttpRequest();
else
{
try
{
req=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try { req=new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc){ req=null;}
}
}
return req;
}
var reqChat = null;
reqChat = InitializeXMLHttpRequest(reqChat);
reqChat.onreadystatechange = ProcessCheckStatusResult;
function ProcessCheckStatusResult(){
status+='+';
if (reqChat.readyState == 4){
if (reqChat.status == 200){
alert("ok");
}
}
}
function CheckStatus(){
status+=' send';
var url = "2.htm?t=" + new Date().getTime();
reqChat.open('GET', url, true);
reqChat.send(null);
}
status='';
setInterval(CheckStatus, 5000);
</script>
</body>
</html>
I use XMLHttpRequest in order to periodically ask server for some
data. I use code I have used many times before (but not in a loop).
It works fine in Firefox but not in IE .
In IE it executes only time, then "send" method executes as it should
but method attached to "onreadystatechange" never called.
I mean
.... send ...
.... an event handler for onreadystatechange ...
.... send ...
.... send ...
.... send ...
.... send ...
Could anybody give me a suggestion about reasons of that behaviour?
Regards, Mykola
http://marss.co.ua
Below is a snippet to illustrate the situation.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>String Build Performance Tester</title>
</head>
<body>
<script type="text/javascript">
function InitializeXMLHttpRequest(req)
{
if (req != null)
req.abort();
if (typeof XMLHttpRequest != "undefined")
req = new XMLHttpRequest();
else
{
try
{
req=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try { req=new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc){ req=null;}
}
}
return req;
}
var reqChat = null;
reqChat = InitializeXMLHttpRequest(reqChat);
reqChat.onreadystatechange = ProcessCheckStatusResult;
function ProcessCheckStatusResult(){
status+='+';
if (reqChat.readyState == 4){
if (reqChat.status == 200){
alert("ok");
}
}
}
function CheckStatus(){
status+=' send';
var url = "2.htm?t=" + new Date().getTime();
reqChat.open('GET', url, true);
reqChat.send(null);
}
status='';
setInterval(CheckStatus, 5000);
</script>
</body>
</html>