Skip to content

Instantly share code, notes, and snippets.

@kjunine
Created July 25, 2013 06:46
Show Gist options
  • Select an option

  • Save kjunine/6077407 to your computer and use it in GitHub Desktop.

Select an option

Save kjunine/6077407 to your computer and use it in GitHub Desktop.
CORS GET example for MSIE 8 & 9
var callback = function(data) { console.log(data); };
var url = "http://somewhere.in/the.web";
if (windows.XDomainRequest) {
var xdr = new XDomainRequest();
xdr.open("get", url);
xdr.onload = function() {
callback(this.responseText, 'success');
};
xdr.send();
} else {
if (windows.XMLHttpRequest) {
$.get(url, callback);
} else {
// doesn't work
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment