473,543 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to check progress of XMLHTTPRequest?

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.
Mar 30 '06 #1
10 11308

test wrote:
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.


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>102 325</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.

Mar 30 '06 #2
test wrote:
If you know of some alternative way to make a
progress bar for this purpose, let me know.


Sorry, I don't help anonymous address mungers.

<URL:http://www.interhack.n et/pubs/munging-harmful/>
PointedEars
Mar 30 '06 #3
Thomas 'PointedEars' Lahn wrote:
Sorry, I don't help anonymous address mungers.
<URL:http://www.interhack.n et/pubs/munging-harmful/>


Yet you waste everyone's time posting stupid responses like this?
Or ones that simply say "RTFM"?

Come on, please don't litter this group with more junk than it already has!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 31 '06 #4
salute Mr. test

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:
...
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.


.... and yet it is worth a try to access some of these informations.

listen to the [[XMLHttpRequest]] objects "onreadystatech ange".
as long as the objects "readyState " returns its interactive status 3
try to read the objects "responseStream .length" property and as this
fails the objects "responseText.l ength" property as well.

when I did research in order to script just another XMLHttpRequest
interface I found "responseStream " only (no other reference states
something to "responseStream ") at
[http://msdn.microsoft.com/library/en...sp?frame=true]
and I implemented it - but my test running in MSIE always switches
to the "responseText.l ength" fallback.

now you got the information about the objects "bytesLoade d".
you will receive the objects "totalBytes " as result of the following
header query: [[XMLHttpRequest]].getResponseHea der("Content-Length");

the rest simply is Math.

you might countercheck my test as a feasibility study at
[http://www.pseliger.de/testCases/dht...face.dev.html]
so long - peterS.

Mar 31 '06 #5
Matt Kruse wrote:
Thomas 'PointedEars' Lahn wrote:
Sorry, I don't help anonymous address mungers.
<URL:http://www.interhack.n et/pubs/munging-harmful/>


Yet you waste everyone's time posting stupid responses like this?


What you call a stupid response and a waste of time, I call giving a hint,
so that OPs recognize why they do not receive help (from me) even though it
would have been possible, and therefore giving them an incentive to change
their antisocial behavior.
PointedEars
Mar 31 '06 #6
Thomas 'PointedEars' Lahn said the following on 3/31/2006 8:33 AM:
Matt Kruse wrote:
Thomas 'PointedEars' Lahn wrote:
Sorry, I don't help anonymous address mungers.
<URL:http://www.interhack.n et/pubs/munging-harmful/> Yet you waste everyone's time posting stupid responses like this?


What you call a stupid response and a waste of time,


Is a stupid response and a waste of time. Call it what it is.
I call giving a hint,
99.99% of the post in this group can be answered with an RTFM. Its a
stupid, useless response. Its not a hint.

so that OPs recognize why they do not receive help (from me) even though it
would have been possible, and therefore giving them an incentive to change
their antisocial behavior.


Practice what you preach, please?

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 31 '06 #7
On 31 Mar 2006 01:38:36 -0800, peterS. wrote:
salute Mr. test

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:
...
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.


... and yet it is worth a try to access some of these informations.

listen to the [[XMLHttpRequest]] objects "onreadystatech ange".
as long as the objects "readyState " returns its interactive status 3
try to read the objects "responseStream .length" property and as this
fails the objects "responseText.l ength" property as well.

when I did research in order to script just another XMLHttpRequest
interface I found "responseStream " only (no other reference states
something to "responseStream ") at
[http://msdn.microsoft.com/library/en...sp?frame=true]
and I implemented it - but my test running in MSIE always switches
to the "responseText.l ength" fallback.

now you got the information about the objects "bytesLoade d".
you will receive the objects "totalBytes " as result of the following
header query: [[XMLHttpRequest]].getResponseHea der("Content-Length");

the rest simply is Math.

you might countercheck my test as a feasibility study at
[http://www.pseliger.de/testCases/dht...face.dev.html]
so long - peterS.


Thanks!

But I seem to have a problem: I don't recieve the
"Content-Length" header. According to Firefox's Firebug
extension, I get these headers:

GET http://localhost/mytestsite/getmessages.php?param=0
Headers:

Date: Fri, 31 Mar 2006 19:53:20 GMT
Server: Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.8
PHP/5.0.5 mod_autoindex_c olor
X-Powered-By: PHP/5.0.5
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Is it something I have to set on the server? How?
Mar 31 '06 #8
On Fri, 31 Mar 2006 22:06:07 +0200, test wrote:

[...]
Is it something I have to set on the server? How?


OK, I've set it on the php side with:

header('Content-length: '.filesize($fil e));

Thanks again for your reply :)
Mar 31 '06 #9
JRS: In article <13************ ****@PointedEar s.de>, dated Fri, 31 Mar
2006 15:33:09 remote, seen in news:comp.lang. javascript, Thomas
'PointedEars' Lahn <Po*********@we b.de> posted :
Matt Kruse wrote:
Thomas 'PointedEars' Lahn wrote:
Sorry, I don't help anonymous address mungers.
<URL:http://www.interhack.n et/pubs/munging-harmful/>


Yet you waste everyone's time posting stupid responses like this?


What you call a stupid response and a waste of time, I call giving a hint,
so that OPs recognize why they do not receive help (from me) even though it
would have been possible, and therefore giving them an incentive to change
their antisocial behavior.

Your manner of posting is itself antisocial behaviour; follow,
therefore, your own advice. When you have nothing useful to say, then
say nothing.

You seem to consider yourself to have been elected fuehrer of this
newsgroup - you are mistaken.

While your technical ability is, although unreliable, acknowledged,
opinions on you evidently vary. Sometimes you are despised, sometimes
you are hated, but most often you seem to be considered psychologically
inadequate or mentally malformed. Even your fellow Germans over in
de.c.l.j seen to hold similar views.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Apr 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3674
by: John Salerno | last post by:
My code is below. The main focus would be on the OnStart method. I want to make sure that a positive integer is entered in the input box. At first I tried an if/else clause, then switched to try/except. Neither is perfect yet, but I was wondering which I should try for in the first place. I figure I need to check for an emptry string,...
25
29713
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden" name="ClickedElement" id="Messenger" /> </form> </body>
4
2703
by: libsfan01 | last post by:
Hi all I want to have create a js function to use xmlhttprequest continously check a given url for any change in its value and then bring the contents of that page through. Here is my code so far, it just pulls is through once when the function is called, i would like it to work continuously: function getdata() {
8
3878
by: Chandra | last post by:
How do I programmatically (javascript) check if link is valid in html?
1
4015
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to...
1
3275
by: Mike P | last post by:
I am trying to apply the Update Progress control to a method that is building a zip file and then giving the user the chance to save the file via a popup box. But the Update Progress control doesn't seem to like this. I am getting the error : 'Sys.WebForms.PageRequestManagerParserErrorException. The message received from the server could...
4
3989
by: avicalc | last post by:
I need help with the structure of a JavaScript program. My process is as follows: 1) Get JSON data via XMLHttpRequest. 2) When done with the above, process the JSON data which may take up to 3 seconds. 3) Because of the possibility of a time consuming operation, display a simple animation ("Loading...", etc) while the user is waiting. ...
12
4353
by: canabatz | last post by:
i got this php file 'check.php' that checks for changes ,and showing a counter for posts !! $show_data="SELECT * FROM bidding_main WHERE bid_id='$bid_id' "; $show_data_query=mysql_query($show_data); $num_show_data=mysql_num_rows($show_data_query); $sqlno="SELECT * FROM bidding_details WHERE bid_id=$bid_id "; $queryno=mysql_query($sqlno);...
0
7590
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7733
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7344
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7684
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5264
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
963
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
633
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.