...

View Full Version : possible to calculate percent download complete with AJAX?



hotwheelharry
01-05-2009, 08:48 PM
If I have a file on my server and I am requesting it via Ajax on the client, is it possible to get the amount downloaded at any one point in bytes or Kb so far.

I don't want to use the readyState property (the 0-4 number)
it's not precise and cool looking. hehe

This would be so I could display a loading bar type thing.

Any info welcome :D

rnd me
01-05-2009, 09:05 PM
firefox has a progress event.
if you know the total size, you can calc the % by examining the length of responseText for browsers that return partial responses.

hotwheelharry
01-06-2009, 11:38 PM
what "readyState" has a partial responseText in the browsers that return partial when loading?

i would guess readyState 3, but i'm not too sure.

Or, just when do the browsers that return partial responseText return the partial bits.

Thank you.

btw, rnd_me, you have mad knowledge skillz. you always answer my posts! :thumbsup:

rnd me
01-07-2009, 12:26 AM
what "readyState" has a partial responseText in the browsers that return partial when loading?

i would guess readyState 3, but i'm not too sure.

Or, just when do the browsers that return partial responseText return the partial bits.


i don't know the browser/server combos that leach responseText offhand, but it's a crappy way of doing it anyway.
check out this article (http://ajaxpatterns.org/Progress_Indicator) for more info on why.

running a 2nd, repeating ajax call to check status of a big request is how some sites handle it.
it require a little extra server coding, but is the only cross-browser way of doing a reliable progress update.

hotwheelharry
01-10-2009, 09:39 PM
k, thanks for the link.
A little extra server coding is no biggie for me, so i will try it with the extra request method.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum