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

XMLHttpRequest not sending progress event

1,521 views
Skip to first unread message

Erik

unread,
Jun 12, 2009, 2:42:01 PM6/12/09
to
Regarding the following code snippet from:

https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress

var req = new XMLHttpRequest();
req.addEventListener("progress", updateProgress, false);

I noticed that when calling the XML API on the eBay web server that the
"progress" event never gets fired, not even with event.lengthComputable
set to false. However the "load" event does fire in my code.

Here are the response headers from the request object:

Depot log: Date: Fri, 12 Jun 2009 18:29:59 GMT
Server: Apache-Coyote/1.1
X-EBAY-API-POOL-NAME: ___cDRidW9ubXFq
X-EBAY-API-SERVER-NAME: ___dW0ucnJibnU2MjMqNzctNDcpNTYoNTA0PD8zPTc=
Content-Type: text/xml
X-Cache: MISS from smfapigw007.smf.ebay.com, MISS from
smfapigw007.smf.ebay.com
Content-Encoding: gzip
Content-Length: 18708
Connection: close

As you can see the server is definitely returning "Content-Length", so I
presume that XMLHttpRequest should be able to report progress. Is the
lack of progress events due to Firefox reading the entire response from
the socket in one go without waiting or is this a bug in XMLHttpRequest?
I'm running my code Firefox 3.5 beta 4.


Regards,
Erik

Jonas Sicking

unread,
Jun 12, 2009, 6:35:47 PM6/12/09
to

Are you adding the eventlistener before calling open(). I think we have
a bug somewhere where if you don't add the event listener early enough
(don't remember if it's before open() or before send()), then we won't
fire progress events.

If that doesn't help, please file a bug and attach a testcase. And link
to the bug in this thread.

/ Jonas

Erik

unread,
Jun 13, 2009, 11:52:39 AM6/13/09
to
Jonas Sicking wrote:
> Are you adding the eventlistener before calling open(). I think we have
> a bug somewhere where if you don't add the event listener early enough
> (don't remember if it's before open() or before send()), then we won't
> fire progress events.

Ok, I moved it from just before send() to before open() and it now
works. It's a pity Mozilla doesn't mention this on their website, I can
see it driving many people crazy for hours on end wondering why it's not
working.


Regards,
Erik

Christopher Blizzard

unread,
Jun 13, 2009, 1:16:03 PM6/13/09
to Erik, dev-pl...@lists.mozilla.org

I don't think it was documented because we didn't know about it. I've
added a note to the docs that says that. Thanks for reporting the
problem - we appreciate it!

--Chris

Boris Zbarsky

unread,
Jun 13, 2009, 2:13:36 PM6/13/09
to
Christopher Blizzard wrote:
> I don't think it was documented because we didn't know about it.

Actually, we sort of did. The documentation for onuploadprogress in
nsIXMLHttpRequest.idl says, for example:

385 * This event listener must be set BEFORE calling open().

-Boris

Erik

unread,
Jun 13, 2009, 3:05:36 PM6/13/09
to
Boris Zbarsky wrote:
> Actually, we sort of did. The documentation for onuploadprogress in
> nsIXMLHttpRequest.idl says, for example:
>
> 385 * This event listener must be set BEFORE calling open().

Fair enough, though I have to admit I never look at the interface
definitions, I usually just read the main tutorials and documentation
pages. In this case I was looking at the "In Firefox 3.5 and later"
section of:

https://developer.mozilla.org/En/Using_XMLHttpRequest

It's nice to see that Christopher Blizzard has added a note to that page
now.


Regards,
Erik

0 new messages