Created
April 4, 2012 12:29
-
-
Save olimortimer/2300792 to your computer and use it in GitHub Desktop.
JS: Cross-domain jQuery JSON AJAX alternative for IE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The ajax.php file must also return header('Access-Control-Allow-Origin: *'); | |
if ($.browser.msie && window.XDomainRequest) { | |
// Use Microsoft XDR | |
var xdr = new XDomainRequest(); | |
xdr.open("POST", js_base_url + 'ajax?id='+id); | |
xdr.onload = function () { | |
var JSON = $.parseJSON(xdr.responseText); | |
alert(JSON.response); | |
}; | |
xdr.send(); | |
} else { | |
$.ajax({ | |
type: 'POST', | |
url: js_base_url + 'ajax', | |
data: {id: id}, | |
dataType: 'json', | |
success: function(data) { | |
alert(data.response); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment