Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

onReadyStateChange callback vs. "load" event

187 views
Skip to first unread message

Jan Odvarko

unread,
Jul 21, 2009, 2:22:47 PM7/21/09
to
We are currently facing a problem with Firebug's XHR Spy
(XmlHttpRequest monitor that logs XHRs into the Firebug Console panel)
which is broken due to:
https://bugzilla.mozilla.org/show_bug.cgi?id=502959

The current problem is with the way how Firebug handles end of the
XHR. The current implementation replaces "onreadystatechange" callback
of each XHR with own callback and executes the original by calling
previousCallback.handleEvent(event). Unfortunately this doesn't work
due to the bug above.

Notice that the "onreadystatechange" is used to only handle the state
== 4 (the end of the request).

I would like to commit a workaround that fixes this (by not using the
onreadystatechange) but following listeners instead:

xhr.addEventListener("load", function() {}, true);
xhr.addEventListener("error", function() {}, true);

As far as I understood the logic the "load" event is *equivalent* to
onReadyStateChange (state==4) and the only difference is that "load"
is not called when an error occurs while transferring the file. So,
Firebug must use yet the "error" event listener.

Is this correct?

Are there any other cases when "load" event differs from
"onreadystatechange" callback?
i.e. "load" isn't fired while "onreadystatechange" callback is called?

Honza

p.fr...@gmail.com

unread,
Jun 25, 2012, 5:56:50 PM6/25/12
to

p.fr...@gmail.com

unread,
Jun 25, 2012, 5:56:22 PM6/25/12
to
Il giorno martedì 21 luglio 2009 20:22:47 UTC+2, Jan Honza Odvarko ha scritto:
0 new messages