24

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 request. The funny thing is we've got it working fine in IE8/9/10 just not 11.

The problem is that IE 11 appears to timeout and not wait for a response from the server. The ajax call is simply:

$.ajax(url, {
    dataType: 'json',
    complete: complete,
    type: 'GET',
    global: true,
    success: success,
    crossDomain: true,
    xhrFields: {
        withCredentials: true
    }
});

In the network tab and using Fiddler I can see IE never even sends the request.

Does anyone have any ideas please?

EDIT: I forgot to mention I've already tried cache: false. I've also found something very strange in that if I switch document mode in dev tools from Edge to 9 then back again the call works everytime, even after I've cleared IE and restarted it, whether cache is true or false. Very bizarre. :\

8
  • Can you see if IE11 has issues with the pre-flight OPTIONS request? Can you log the OPTIONS request on the server?
    – Halcyon
    Commented Nov 26, 2013 at 14:24
  • debug it by checking which option of ajax give you issue
    – A. Wolff
    Commented Nov 26, 2013 at 14:24
  • I don't know if this is still an issue, but have you checked your IE security zones to allow CORS?
    – rockerest
    Commented Nov 26, 2013 at 14:25
  • Sorry I should have mentioned I've already tried setting cache:false. IE has no issues with the OPTIONS request either.
    – Daveo
    Commented Nov 26, 2013 at 14:32
  • 1
    @SandeepNayak I can't believe I forgot to accept an answer for this, thanks for reminding me. :)
    – Daveo
    Commented Mar 10, 2017 at 14:07

5 Answers 5

34

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

5
  • Thank you for your reply. I've tried adding the time stamp but it makes no difference.
    – Daveo
    Commented Nov 26, 2013 at 15:55
  • @Daveo : Are you getting any script errors ? Use firebug to see what happens
    – Shyju
    Commented Nov 26, 2013 at 16:01
  • 1
    There should probably be a questionmark before $.now(), otherwise the url will break.
    – qwerty
    Commented Nov 27, 2013 at 7:31
  • I had the similar issue only in IE for an MVC Application, where cached data was causing error. After adding cache:false, it works as intented
    – Betsen
    Commented Apr 5, 2016 at 16:29
  • Thank you @Shyju, it saved my efforts and fix issue with simple parameters Commented Jan 13, 2020 at 9:14
5

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()
4

Uses this in your in head tag

<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">
2

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.

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.