XmlHttpRequest.onload not called
The onload
handler won't be called for yet another reason, I'm adding it here just so it can be helpful to someone else referencing this page.
If the HTTP response is malformed, the onload
handler will not be called either. For example, a plaintext response of 10 bytes that advertises a length of 14 in Content-Length
header will not invoke the onload
handler. I wasted hours on client code before I start to replace back-end units with test stubs.
It looks like it was indeed a XSS issue and Firefox was blocking the onload
call. I can't still understand why the http network request was actually being done and the onreadystatechange
was being called with the DONE
readyState.
I changed the URL to another one in the same domain, and now it works in Firefox (after some cache-related false attempts) and in Chrome. It still does not work in IE8, despite the official docs say it is supported. I've found this SO answer which states otherwise. It looks like the onload
function is a more modern convenience method and the old way of checking the result is using onreadystatechange
instead.
I guess I'll accept this answer as the solution unless a more detailed answer is provided.