onReadyStateChange not firing in IE for XHR Request

后端 未结 2 1093
死守一世寂寞
死守一世寂寞 2021-01-28 13:50

I have this code that I am using and it works fine in chrome, but in IE, it looks like that onreadystatechenge is not firing.

How do I get this to work cross browser. I

相关标签:
2条回答
  • 2021-01-28 14:20

    Apparently IE 11 (which I assume is what you are testing is broken) removed script.onreadystatechange in favor of script.onload.

    Here is the compatibility for xhr.onload.

    Source of IE11 removing it

    0 讨论(0)
  • 2021-01-28 14:26

    Your XMLHttpRequest object might be caching.

    Try:

    var myNoCachePage = document.location + '?' + new Date().getTime();
    xhr.open("GET", myNoCachePage, true);  // Prevent IE11 from caching
    xhr.send();
    
    0 讨论(0)
提交回复
热议问题