1

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

spreiter301
  • 314
  • 1
  • 12
  • Have you considered using a JS framework that provides consistent functionality across browsers? – Pekka Nov 11 '10 at 19:32
  • I've tried jQuery and YUI but they don't seem to support this. Do you know one that supports HTTP streaming? – spreiter301 Nov 11 '10 at 20:06
  • I recall reading somewhere that you're not guaranteed to hit every `readyState` when using the `onreadystatechange` event. – drudge Nov 11 '10 at 23:01

1 Answers1

0

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.

Knu
  • 14,806
  • 5
  • 56
  • 89
Andrew
  • 13,757
  • 13
  • 66
  • 84