I'm setting up a fallback for IE 8 and 9, for which I'm using JQuery to send a cross domain GET request. I am testing using IE 11 in emulation mode for IE8 and 9.
The server is correctly set up for CORS, and has been tested with plain JavaScript XMLHttpRequest for cross domain requests.
The request code in an IE8/9 context is as follows:
$.ajax({ type:"GET", url: url, beforeSend : function(xhr) { xhr.setRequestHeader('Api-Version', config.apiVersion); xhr.setRequestHeader('Api-Account-Key', config.accountKey); xhr.setRequestHeader('Api-Authorisation-Key', config.authorisationKey); }, success: function(data) { callback(data); } }); When sending a request cross domain (the site is running under a non localhost domain at this point) it is clear that the custom headers are not being sent, and this is not an OPTIONS request (output from Fiddler debugger).
GET http://localhost:35000/api/example-url HTTP/1.1 Accept: */* Origin: http://dev.local Accept-Language: en-GB Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko Host: localhost:35000 DNT: 1 Connection: Keep-Alive Pragma: no-cache If I send the request from the same domain, using the same code, the headers are set as I would expect.
GET http://localhost:35000/api/example-url HTTP/1.1 x-requested-with: XMLHttpRequest Accept-Language: en-gb Referer: http://localhost:35000/Documentation access-control-request-headers: x-requested-with api-account-key: xxxxxx Accept: */* api-version: 1.0 api-authorisation-key: xxxx Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko Host: localhost:35000 DNT: 1 So what is stopping JQuery, or possibly the browser sending headers in a cross domain context?
XDomainRequest, which jQuery does not (and will not) support.