javascripthttpstreamingcomet

IE7/8 responseText in readyState 3 not available


I've written an application with tornado to support real time updates on my website through HTTP streaming. It works in all browsers except IE7 and IE8. Here is the code that handles the HTTP streaming:

... code to create xhr object
xhr.open('GET', 'http://192.168.0.173:8888', true);
xhr.onreadystatechange = function() {
        if(xhr.readyState == 3 && xhr.status==200) {
        try {
            alert(xhr.responseText);
        } catch(e) {
            alert("noo");
        }
    }
}
setTimeout("xhr.send(null);", 1000);

The problem is that xhr.responseText is not available when readyState is 3. After a few hours of google I learned about IXMLHTTPRequest.responseStream. I tried to use

xhr = new ActiveXObject("MSXML2.XMLHTTP.3.0");

but with the same result. The request is sent to the server and readyState is 3 but xhr.responseStream is not available.

Any ideas? Or should I fall back to long polling when I detect IE?

Thank you

Henry


Solution

  • If you read your linked page again;

    In comparison, the Microsoft XML (MSXML) version of the IXMLHTTPRequest interface exposes partial results through the responseStream property, which the Windows Internet Explorer native version does not implement. Be aware that this behavior also differs from the IServerXMLHTTPRequest interface, which provides partial results to responseBody and responseText.

    That is, I guess, one needlessly complicated way of saying, this thing exists, but we don't do it. Useless IE. I just had to implement that same thing and ended up just falling back to long polling for IE.

    The Dojo foundation has Cometd using Bayeux. But I believe only Jetty currently implements the Bayeux protocol.

    So in conclusion, IE, DIAF.