I am using jQuery's .ajax to pull in content from other pages into a modal window. The majority of these pages are on the same domain and work correctly across all browsers.
There is one link that goes to another domain. That link works correctly in Chrome, Firefox, and Safari but gives an Access Denied error in Internet Explorer 8 and 9.
I searched quite a bit for a solution and tried several things that have not helped so far including:
- I confirmed Access-Control-Allow-Origin was set to allow my domain. I tried setting it to "*" as well just to confirm that wasn't the issue.
- I tried using different jQuery methods to make the AJAX call. I used jQuery's load, get, and ajax methods. jQuery's ajax method gave me the Access Denied error.
- I tried using Internet Explorer's XDomainRequests. XDomainRequests told me there was an error but gave me no more information. I tried several changes to this code I found suggestions for like setting a timeout on the send function but no change.
- I set jQuery.support.cors = true; and added crossDomain: true to my .ajax call.
- I found someone who suggested that jQuery version 1.8.0 caused the issue which happens to be the version that is used on the website I am working on. The suggestion they had was to step back to version 1.7.2 which did not fix the issue. I also tried changing to version 1.11.0 but that also did not make a difference.
- I saw a suggestion that adding &callback=? to the end of the url would solve it but that didn't make a difference.
I am probably forgetting something that I tried today but that should be most of it.
Here is the code I have at the moment:
jQuery.support.cors = true;
var request = $.ajax(
{
crossDomain: true,
type: "GET",
url: url,
success: function () {
console.log('success');
},
error: function (a, status, error) {
console.log('error: ' + error);
},
complete: function () {
console.log('complete');
}
});
Chrome, Firefox, and Safari log 'success' and 'complete' in the console. IE8/9 log 'error: Error: Access is denied.' and 'complete' in the console.