简体   繁体   中英

Cross Domain AJAX Request is not working on IE10

I sent ajax request from 'sub.example.com' to 'www.example.com/api/lists'(yes, it is subdomain), but it's not working only IE. It's working on FF, Chrome, Safari and other mobile browser.

Error Message - SEC7120 : Origin http://sub.example.com is not allowed by Access-Control-Allow-Origin.

My server setting is

<?php
  header('Access-Control-Allow-Origin : *');
  header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');

I tried two ways. first, jQuery.ajax();

$.ajax({
  url : 'http://www.example.com/api/lists',
  type : 'GET',
  dataType : 'JSON',
  cache : false,
  crossDomain : true
}).success(function(data){
  // do something
});

and navtive javascript.

 var xhr = new XMLHttpRequest();
 xhr.open('GET', 'http://www.example.com/api/lists');
 xhr.send();

both of them not working only IE10 Browser.(not tested lt IE10 yet)

Remove the space between the colon and the asterisk.

Change

header('Access-Control-Allow-Origin : *');

to

header('Access-Control-Allow-Origin: *');

Internet Explorer is quite unflexible when it comes to correct syntax.

You may be facing an IE10 issue , and the ticket on JQuery has been closed as this is an issue with IE10 itself.

The 'workaround' at the moment is to set compatibility mode:

<meta http-equiv="x-ua-compatible" content="IE=9" >

It is also worth reading through the post I've linked to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM