XmlHttpRequest.onload not called

前端 未结 3 1982
星月不相逢
星月不相逢 2021-02-20 10:39

I\'m playing around with this XmlHttpRequest thing. In some tutorials and books, it is the onload function the one that is called when the request is d

3条回答
  •  野性不改
    2021-02-20 11:14

    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.

提交回复
热议问题