IE7/8 responseText in readyState 3 not available

吃可爱长大的小学妹 提交于 2019-12-11 05:08:41

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/4158435/ie7-8-responsetext-in-readystate-3-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!