如何检查XMLHTTPRequest的进度? [英] How to check progress of XMLHTTPRequest?

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

问题描述




我想使用

XMLHTTPRequest异步接收大量数据。如果有可能,我想制作一个

进度条向用户显示流程的进展情况。


根据我发现的信息,该对象在五个州中只能是
(如下所示)。当对象处于状态3时,是否可以看到已收到多少

数据?


XMLHttpRequest.readyState:


0该对象已创建,但尚未初始化(尚未调用打开的

方法)。

1该对象已创建,但是发送方法没有被调用


2调用了send方法,但状态和标题

尚不可用。

3已收到一些数据。在此状态下调用responseBody和

responseText属性以获取

部分结果将返回错误,因为状态

和响应标头不完整可用。

4已收到所有数据,完整数据为

可用。


如果你知道一些另一种制作进度条的方法

这个目的,让我知道。

Hi,

I want to asynchronously recieve large amount of data using
XMLHTTPRequest. If it is possible, I would like to make a
progress bar to show the user how the process is going.

According to the information I found, the object can only be
in five states (shown below). Is it possible to see how much
data has already been recieved when the object is in state 3?

XMLHttpRequest.readyState:

0 The object has been created, but not initialized (the open
method has not been called).
1 The object has been created, but the send method has not
been called.
2 The send method has been called, but the status and headers
are not yet available.
3 Some data has been received. Calling the responseBody and
responseText properties at this state to obtain
partial results will return an error, because status
and response headers are not fully available.
4 All the data has been received, and the complete data is
available.

If you know of some alternative way to make a progress bar for
this purpose, let me know.

推荐答案



test写道:

test wrote:


我想使用
XMLHTTPRequest异步接收大量数据。如果有可能,我想制作一个进度条向用户显示进程的进展情况。

根据我发现的信息,对象只能是
五个州(如下所示)。当对象处于状态3时,是否可以看到已收到多少
数据?

XMLHttpRequest.readyState:

0对象已创建,但未初始化(未打开
方法)。
1对象已创建,但发送方法尚未调用。
2发送方法已被调用,但状态和标题
尚未可用。
3已收到一些数据。在此状态下调用responseBody和
responseText属性以获取部分结果将返回错误,因为状态
和响应标头不完全可用。
4所有数据都已收到了,完整的数据可用。

如果您知道为此目的制作进度条的其他方法,请告诉我。
Hi,

I want to asynchronously recieve large amount of data using
XMLHTTPRequest. If it is possible, I would like to make a
progress bar to show the user how the process is going.

According to the information I found, the object can only be
in five states (shown below). Is it possible to see how much
data has already been recieved when the object is in state 3?

XMLHttpRequest.readyState:

0 The object has been created, but not initialized (the open
method has not been called).
1 The object has been created, but the send method has not
been called.
2 The send method has been called, but the status and headers
are not yet available.
3 Some data has been received. Calling the responseBody and
responseText properties at this state to obtain
partial results will return an error, because status
and response headers are not fully available.
4 All the data has been received, and the complete data is
available.

If you know of some alternative way to make a progress bar for
this purpose, let me know.




您可以通过一次只发送一个请求的X数据,然后

请求您的总数据N的下一个X段。像

这个...


< part>

< bytesSent> 1256< / bytesSent>

< bytesTotal> 102325< / bytesTotal>

< data>插入您在此处发送的任何数据,部分

整个< / data>

< / part>


继续请求下一部分N数据,阅读,更新您的页面,

,直到您有字节为止总计。



You could do it by only sending X data of a request at a time, then
requesting the next X segment of your total data N. Something like
this...

<part>
<bytesSent>1256</bytesSent>
<bytesTotal>102325</bytesTotal>
<data>insert whatever data you are sending here, part of the
whole</data>
</part>

Keep requesting the next part of N data, reading, updating your page,
until you have bytes total.


test写道:
test wrote:
如果你知道一些替代方法来制作一个
为此目的的进度条,让我知道。
If you know of some alternative way to make a
progress bar for this purpose, let me know.




对不起,我不会帮忙匿名地址mungers。


< URL:http://www.interhack.net/pubs/munging-harmful/>

PointedEars



Sorry, I don''t help anonymous address mungers.

<URL:http://www.interhack.net/pubs/munging-harmful/>
PointedEars


Thomas'' PointedEars''Lahn写道:
Thomas ''PointedEars'' Lahn wrote:
对不起,我不会帮忙匿名地址mungers。
< URL:http://www.interhack.net/pubs/munging-harmful/ >
Sorry, I don''t help anonymous address mungers.
<URL:http://www.interhack.net/pubs/munging-harmful/>




但是你浪费大家的时间发布这样的愚蠢回答?

或者只是简单地说RTFM?


加油,请不要乱扔垃圾比现有垃圾更多!


-

Matt Kruse
http://www.Java scriptToolbox.com
http://www.AjaxToolbox.com


这篇关于如何检查XMLHTTPRequest的进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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