Skip to content

Instantly share code, notes, and snippets.

@smgt
Created February 17, 2012 06:34
Show Gist options
  • Save smgt/1851290 to your computer and use it in GitHub Desktop.
Save smgt/1851290 to your computer and use it in GitHub Desktop.
// Create a new object
ajax = new XMLHttpRequest();
// Try to open a API resource that won't return a 200 or 201
ajax.open("GET", "https://api.flattr.com/rest/v2/user", false);
ajax.send();
// The response
ajax.responseText;
// "{"error":"unauthorized","error_description":"You are unauthorized to access the resource","error_uri":"http:\/\/developers.flattr.net\/api\/"}"
ajax.status;
// 401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment