0

I use jquery $.ajax to get Json content from another server. It works fine under Firefox, but not under Chrome and IE 9 (or less). Here is my code:

$.ajax({
    type: "GET",
    url: query,
    dataType: "json",
    headers : {
        "Accept-Datetime" :  "Fri, 15 Feb 2013 00:00:00 GMT",
        "Authorization" : auth code,
    },
   success: processData,
   error: function(xhr, status, error){ console.log(xhr.responseText, status, error);}
}); 

It shows the message "XmlHttpRequest cannot load ajax call [my url]. Origin [my domain] is not allowed by Access-Control-Allow-Origin" in console mode. The platform I use is just HTML. It does not allow PHP. So I can only use Jquery. Can anyone help? Cheers.

Alex
  • 9,831
  • 13
  • 29
  • 37

2 Answers2

1

jQuery.support.cors = true; before the call should enable cross domain JSON data

Balint Bako
  • 2,468
  • 1
  • 13
  • 13
0

Modern browsers will not allow you to make Ajax calls between different domains. You'll have to set up permissions in crossdomain.xml or use a JSONP call. There's plenty other information about this on SO:

XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin

Community
  • 1
  • 1
Mataniko
  • 2,172
  • 15
  • 18