For IE8 and IE9 you need to use XDomainRequest (XDR). If you look below, you will see it in a similar formatting like $ .ajax. As for my research, I cannot get this cross-domain working environment in IE6 and 7 (still looking for a job for this). XDR first appeared in IE8 (it is also in IE9). So, first of all, I'm testing 6/7 and not doing AJAX.
IE10 + can perform cross-domain like all other browsers (congrats Microsoft ... sigh)
After this else, if the tests for XDomainRequest are in the window (apparently better than browsing the browser) and makes an AJAX JSON request in the same way, the other, as a rule, ELSE does this usually with $ .ajax.
Hope this helps! Took me forever to get it all originally
XDomainRequest Object Information
// call with your url (with parameters) // 2nd param is your callback function (which will be passed the json DATA back) crossDomainAjax('http://www.somecrossdomaincall.com/?blah=123', function (data) { // success logic }); function crossDomainAjax (url, successCallback) { // IE8 & 9 only Cross domain JSON GET request if ('XDomainRequest' in window && window.XDomainRequest !== null) { var xdr = new XDomainRequest(); // Use Microsoft XDR xdr.open('get', url); xdr.onload = function () { var dom = new ActiveXObject('Microsoft.XMLDOM'), JSON = $.parseJSON(xdr.responseText); dom.async = false; if (JSON == null || typeof (JSON) == 'undefined') { JSON = $.parseJSON(data.firstChild.textContent); } successCallback(JSON); // internal function }; xdr.onerror = function() { _result = false; }; xdr.send(); } // IE7 and lower can't do cross domain else if (navigator.userAgent.indexOf('MSIE') != -1 && parseInt(navigator.userAgent.match(/MSIE ([\d.]+)/)[1], 10) < 8) { return false; } // Do normal jQuery AJAX for everything else else { $.ajax({ url: url, cache: false, dataType: 'json', type: 'GET', async: false, // must be set to false success: function (data, success) { successCallback(data); } }); } }
Mark Pieszak - DevHelp.Online Jun 29 '12 at 19:37 2012-06-29 19:37
source share