Okay, I've got some code now that works well in all the major browsers
except for IE.  I can't post the code just now but I'll put it up as
soon as I get proper net access back on the other computer.  Oddly it
doesn't throw any errors in IE, it simply doesn't produce any
results.

Gordon wrote:
> I have been thinking about how to do this all morning.  At first I
> thought it wouldn't be possible because the XHR object doesn't seem to
> have a property for the amount of data downloaded.  But I have come up
> with a possible work around.  I have jotted some pseudocode down and
> am researching how well this approach might work, but unfortunately
> something's gone wrong with the firewall at work and my ability to
> browse and find practical solutions is badly compromised just now.
> Anyway, here's my pseudocode:
>
> On (XHR enters stage 3)
> {
>     Create an interval timer;
> }
> On (XHR enters stage 4)
> {
>     Destroy timer;
> }
> On (Timer event)
> {
>     If (fetching XML)
>         Get ResponseXML length;
>     else
>         Get ResponseText length;
>     If (Content-length header set)
>         return (percent downloaded);
>     else
>         return (bytes downloaded);
> }
>
> Gordon wrote:
> > I am trying to figure out a way of displaying how far along an AJAX
> > download is.  Assuming I know the size of the file being downloaded
> > (this will require the server to send a content-length header) then if
> > I can check the number of bytes downloaded thus far I should be able
> > to work out the download progress.
> >
> > So what I need to know, how can you get the value of the content-
> > length header if it is set, and how can you check the number of bytes
> > sent periodically?  I can then display a percentage for the case where
> > both are known, or simply a count of downloaded bytes when I don't
> > know the content length.

Reply via email to