Ajax readystate 3 (Chrome / IE)

我们两清 提交于 2019-12-21 05:38:11

问题


I'm playing around with some comet and mxhr technologys. As it turns out, Chrome (5) does actually fire a readystate 3, but the responseText is always empty there.

Until today I though only InternetExplorers (<8) would show that behavior.

Am I wrong here?

Can somebody confirm that Chrome does not fully support ajax readystate 3 ?


回答1:


After doing a lot of research and reading in webkits developer forum, I finally can tell what is happening and how to prevent that in chrome / webkit / safari.

It's all about the connection type. To make chrome work "correctly" (responseText is NOT null) within ready state 3, we need a content-type which is not subject to sniffing. For instance a Content-type: text/xml works fine.

Another important thing on webkit is that it does not render pushed data until there are enough bytes transfered. "Official" that treshhold is about 256 bytes. So you have to at least send that as a padding.

Anyways on my testing I figured that you need to send a whole lot more before Chrome(5) fires a state3 ajax event the first time. Around 1kb.



来源:https://stackoverflow.com/questions/3256056/ajax-readystate-3-chrome-ie

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