问题描述
我用龙卷风编写了一个应用程序,通过HTTP流媒体支持我网站上的实时更新。它适用于除IE7和IE8之外的所有浏览器。以下是处理HTTP流的代码:
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);
问题是当readyState为3时,xhr.responseText不可用。经过几个小时的google我了解了。我试图使用
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");
但结果相同。请求被发送到服务器,readyState为3,但xhr.responseStream不可用。
but with the same result. The request is sent to the server and readyState is 3 but xhr.responseStream is not available.
有什么想法吗?或者,当我检测到IE时,我应该回到长轮询吗?
Any ideas? Or should I fall back to long polling when I detect IE?
谢谢
Henry
推荐答案
如果您再次阅读链接页面;
If you read your linked page again;
也就是说,我想,一种不必要复杂的说法,这件事存在,但我们不这样做。无用的IE。我只是必须实现同样的事情,最终只是回到IE的长轮询。
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.
使用了Bayeux Cometd。但我相信只有Jetty目前实现了Bayeux协议。
The Dojo foundation has Cometd using Bayeux. But I believe only Jetty currently implements the Bayeux protocol.
总之,IE,DIAF。
So in conclusion, IE, DIAF.
这篇关于readyState 3中的IE7 / 8 responseText不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!