Why isn’t the callback function called in IE?
-
A call to Flickr:
$.getJSON("http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos", { api_key: APIKey, photoset_id: photoSetID, format: "json", per_page: 40, nojsoncallback: 1 }, displayImages); function displayImages(data) { alert('called'); } -
A call to YouTube:
$.getJSON('https://gdata.youtube.com/feeds/api/users/username/favorites?alt=json', function(data) { alert('called'); })
Both of these types of calls work on any other browser, except IE.
Can you please explain me why?
jQuery only supports cross-domain ajax in non-IE<=9 browsers. To use those APIs in IE, you need to use JSONp if available or add a jQuery plugin that adds support for the XDomainRequest api used by IE.
If possible use JSONp; XDR has quite some limitations – see http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx for details.