Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts

    possible to calculate percent download complete with AJAX?

    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
    Last edited by hotwheelharry; 01-05-2009 at 07:51 PM.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    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.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts
    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!

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    Quote Originally Posted by hotwheelharry View Post
    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 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.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #5
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •