XMLHTTPRequest流数据 [英] XMLHTTPRequest streaming data

查看:89
本文介绍了XMLHTTPRequest流数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩XMLHTTPRequest方法来执行客户端/服务器

交易。我现在已经设置好了,当readyState为4时,它需要XML并对其进行处理。这很好用,直到有大量的数据为b $ b。在这种情况下,用户将不得不等待数据返回

,这可能需要一分钟左右。


我不想要用户必须等待。是否有可能定期(虽然仍然收到更多数据)javascript to

停止并显示到目前为止收到的
收到了什么?我想这会被认为是一种类型的

流媒体。


在mozilla / firefox中,我读过我可以使用readyState 3来运行我的回调函数。然后我可以拿走那些4K,解析它们,然后继续。不过我也看过IE不能这样做。
这个。因为我需要这个在IE工作,有没有解决方法?


谢谢,

Scott

I am playing with the XMLHTTPRequest method to perform client/server
transactions. I have it set up right now so that when readyState is 4,
it takes the XML and processes it. This works great until there is alot
of data. In that case, the user will have to wait for the data to come
back which may take a minute or so.

I don''t want the user to have to wait. Is it possible for javascript to
periodically (while still receiving more data) stop and display what it
has received thus far? I guess this would be considered a type of
streaming.

In mozilla/firefox, I have read that I can use readyState 3 to run my
callback function every 4096 bytes. I can then take those 4K, parse
them, and then continue on. However I have also read that IE cannot do
this. Since I need this to work in IE, is there a workaround?

Thanks,
Scott

推荐答案

去********** @ scottsavarese。 com 写道:
我不希望用户必须等待。 javascript
是否有可能定期(同时仍然接收更多数据)停止并显示到目前为止收到的内容?
I don''t want the user to have to wait. Is it possible for javascript
to periodically (while still receiving more data) stop and display
what it has received thus far?




不是那样的我知道。

一个建议 - 使用JSON而不是XML。或者使用您自己的紧凑数据

结构。


XML很冗长,如果
$ b,您可以减少传输时间$ b你使用更紧凑的数据格式。


-

Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com




go ********** @ scottsavarese.com 写道:



go**********@scottsavarese.com wrote:

在mozilla / firefox中,我读过我可以使用readyState 3来每隔4096字节运行一次回调函数。然后我可以拿走那些4K,解析它们,然后继续。不过我也看过IE不能做到这个。由于我需要在IE中使用它,是否有解决方法?
In mozilla/firefox, I have read that I can use readyState 3 to run my
callback function every 4096 bytes. I can then take those 4K, parse
them, and then continue on. However I have also read that IE cannot do
this. Since I need this to work in IE, is there a workaround?




一旦readyState给你

,你应该能够访问responseText交互式值为3.

来自XMLHTTP的MSXML文档:


(3)交互式已收到一些数据。您可以调用

responseBody和responseText属性来获取当前部分

的结果。


-


Martin Honnen
http://JavaScript.FAQTs.com/




Martin Honnen写道:



Martin Honnen wrote:

您应该能够访问responseText,readyState为您提供交互式的值。
来自XMLHTTP的MSXML文档:

(3)交互一些数据已收到。您可以调用
responseBody和responseText属性来获取当前的部分结果。
You should be able to access responseText once readyState gives you the
value 3 for interactive.
From the MSXML docs for XMLHTTP:

(3) INTERACTIVE Some data has been received. You can call the
responseBody and responseText properties to get the current partial
results.




我在这里做了一些测试,尝试访问responseText时

readyState被标记为3,但遗憾的是MSXML总是给

一个例外,即所需的数据尚不可用所以在这个
的情况下它看起来文档很有希望。


-


Martin Honnen
http://JavaScript.FAQTs.com/


这篇关于XMLHTTPRequest流数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆