Skip to content

Instantly share code, notes, and snippets.

@vseventer
Created June 29, 2012 13:36
Show Gist options
  • Select an option

  • Save vseventer/3017968 to your computer and use it in GitHub Desktop.

Select an option

Save vseventer/3017968 to your computer and use it in GitHub Desktop.
Snippet to test whether CORS works properly.
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://baas.kinvey.com/appdata/kidXXXX', true);
xhr.setRequestHeader('Authorization', 'Basic foo:bar');
// Enable the line below to provide Android support.
//xhr.setRequestHeader('X-Kinvey-Origin', 'http://www.example.com');
xhr.onload = function() {
console.log("LOADED", this.status, this.responseText);
};
xhr.onerror = function() {
console.log("ERROR", this.status, this.responseText);
};
xhr.send(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment