Strange AJAX bug with IE 11

前端 未结 5 1084
南笙
南笙 2020-12-25 12:33

I\'m currently working on a purely HTML and JavaScript driven web app that uses CORS for consuming a remote web service but currently having trouble with IE 11 making a GET

相关标签:
5条回答
  • 2020-12-25 13:01

    IE is famous for caching. Make sure you are not getting a cached response. You can either set the cache property value to false or add a unique timestamp to the url so that it will not be a cached response. You may use the $.now() method to get a unique timestamp.

    Setting the cache property

    $.ajax(url, {
        dataType: 'json',
        cache : false,
        //Other things ...
    }
    

    Adding a unique timestamp to URL

    var url="somePage.php?"+$.now();
    //Use this url now for making the ajax call
    

    The $.now() method is a shorthand for the number returned by the expression (new Date).getTime()

    0 讨论(0)
  • 2020-12-25 13:01

    If you are running local, try switching crossDomain to false. I spent quite a bit of time stuck on that. Chrome handled the crossDomain, but in IE if you are not using crossDomain and you have it set to true it will silently fail.

    0 讨论(0)
  • 2020-12-25 13:05

    Uses this in your in head tag

    <meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">
    
    0 讨论(0)
  • 2020-12-25 13:15

    I know this thread is old, but just as an extra check for those that encounter this issue, check that your Trusted Sites Zone settings allow access across domains. The first setting under "Miscellaneous" is the setting you want.

    Set "Access data sources across domains" to "Enable".

    0 讨论(0)
  • 2020-12-25 13:18

    i'm not sure, maybe it's caching, try to set property "cache: false"

    otherwise, you can also try add a datetime at the end of your url, so you have everytime a different url and IE won't cache

    url +""+ (new Date()).getTime()
    
    0 讨论(0)
提交回复
热议问题