Does anyone know a good reference for the various statuses that XmlHttpRequest''s readyState property can have? I mean, I know what the states are, but I''m unclear on the circumstances under which each occurs... In a simple test I wrote, I''m seeing the loaded, interactive and complete states (i.e. my Ajax.Request instance calls its onLoaded, onInteractive and onComplete event handlers). onInteractive gets called multiple times, so I assume it fires either every so-many- bytes of response data or every so-many-seconds -- but which is it? And why isn''t onLoading firing? The reason I''m asking is, I''m trying to implement a progress indicator so there''s some visual feedback while an AJAX request is happening; I''d like to be able to update a progress bar as the AJAX request is processed. So, ideally, I''d like onComplete to called every so-many-bytes of response data, so I don''t have to compare the length of responseText to the Content-length header ;-) L. -- Laurie Harper Open Source advocate, Java geek: http://www.holoweb.net/laurie Founder, Zotech Software: http://www.zotechsoftware.com/
Anyone got any info on this? I''ve been playing around, and tried creating an onInteractive callback to update a progress indicator as the AJAX request loads, but the browser doesn''t seem to redraw reliably while the request is active. Could this be because the rate of calls to onInteractive is too fast for the browser to keep up with the DOM changes it''s trying to make? Or does supplying an onInteractive handler make the AJAX request effectively synchronous? (I don''t know too much about the threading model in Javascript...) L. On 17-Oct-05, at 11:35 PM, Laurie Harper wrote:> Does anyone know a good reference for the various statuses that > XmlHttpRequest''s readyState property can have? I mean, I know what > the states are, but I''m unclear on the circumstances under which > each occurs... > > In a simple test I wrote, I''m seeing the loaded, interactive and > complete states (i.e. my Ajax.Request instance calls its onLoaded, > onInteractive and onComplete event handlers). onInteractive gets > called multiple times, so I assume it fires either every so-many- > bytes of response data or every so-many-seconds -- but which is it? > And why isn''t onLoading firing? > > The reason I''m asking is, I''m trying to implement a progress > indicator so there''s some visual feedback while an AJAX request is > happening; I''d like to be able to update a progress bar as the AJAX > request is processed. So, ideally, I''d like onComplete to called > every so-many-bytes of response data, so I don''t have to compare > the length of responseText to the Content-length header ;-) > > L. > -- > Laurie Harper > Open Source advocate, Java geek: http://www.holoweb.net/laurie > Founder, Zotech Software: http://www.zotechsoftware.com/ > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Laurie Harper Open Source advocate, Java geek: http://www.holoweb.net/laurie Founder, Zotech Software: http://www.zotechsoftware.com/
That won''t work across browsers. Only the onLoading and onComplete callbacks are save to use, the other callbacks may vary in behaviour (or might not be called at all). Thomas Am 18.10.2005 um 05:35 schrieb Laurie Harper:> Does anyone know a good reference for the various statuses that > XmlHttpRequest''s readyState property can have? I mean, I know what > the states are, but I''m unclear on the circumstances under which > each occurs... > > In a simple test I wrote, I''m seeing the loaded, interactive and > complete states (i.e. my Ajax.Request instance calls its onLoaded, > onInteractive and onComplete event handlers). onInteractive gets > called multiple times, so I assume it fires either every so-many- > bytes of response data or every so-many-seconds -- but which is it? > And why isn''t onLoading firing? > > The reason I''m asking is, I''m trying to implement a progress > indicator so there''s some visual feedback while an AJAX request is > happening; I''d like to be able to update a progress bar as the AJAX > request is processed. So, ideally, I''d like onComplete to called > every so-many-bytes of response data, so I don''t have to compare > the length of responseText to the Content-length header ;-) > > L. > -- > Laurie Harper
Ah, too bad :-( Thanks for the warning, though, before I wasted too much time trying to get it to work! The good news is that my fallback solution was to have an animated gif and make it visible in onLoading / hidden in onComplete, so I guess I''ll stick with that. L. On 21-Oct-05, at 3:08 AM, Thomas Fuchs wrote:> That won''t work across browsers. Only the onLoading and onComplete > callbacks are save to use, the other callbacks may vary in > behaviour (or might not be called at all). > > Thomas > > Am 18.10.2005 um 05:35 schrieb Laurie Harper: > > > >> Does anyone know a good reference for the various statuses that >> XmlHttpRequest''s readyState property can have? I mean, I know what >> the states are, but I''m unclear on the circumstances under which >> each occurs... >> >> In a simple test I wrote, I''m seeing the loaded, interactive and >> complete states (i.e. my Ajax.Request instance calls its onLoaded, >> onInteractive and onComplete event handlers). onInteractive gets >> called multiple times, so I assume it fires either every so-many- >> bytes of response data or every so-many-seconds -- but which is >> it? And why isn''t onLoading firing? >> >> The reason I''m asking is, I''m trying to implement a progress >> indicator so there''s some visual feedback while an AJAX request is >> happening; I''d like to be able to update a progress bar as the >> AJAX request is processed. So, ideally, I''d like onComplete to >> called every so-many-bytes of response data, so I don''t have to >> compare the length of responseText to the Content-length header ;-) >> >> L. >> -- >> Laurie Harper >> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Laurie Harper Open Source advocate, Java geek: http://www.holoweb.net/laurie Founder, Zotech Software: http://www.zotechsoftware.com/