Search code examples
jquerygetjsonjquery-1.5

Upgrading to jquery 1.5 leads to issues with .getJSON


I have a part of my present code as follows:

$.getJSON("http://cross.subdomain.url.com", function (data) { alert(data.someobj); //use the data to do some work. } );

The url http://cross.subdomain.url.com, returns json.

This was working perfectly fine , when in jquery 1.4.4.

After updating to jquery 1.5, this has stopped working.

I have tried the following variations of the same:

  1. Changing dataType to json.
  2. Adding "callback?" to the query.

Can someone please shed light on how the jquery ajax object behaves??

Thanks


Solution

  • This issue is also occurring when on the server side the content type is not set to json. On the server side doing the following resolves the issue:

    1. response.setContenyType("text/json");
    2. response.setHeader("Access-Control-Allow-Origin","*");