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
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
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
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
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
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