Skip to content

Instantly share code, notes, and snippets.

@ivangonekrazy
Created November 27, 2013 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivangonekrazy/7681057 to your computer and use it in GitHub Desktop.
Save ivangonekrazy/7681057 to your computer and use it in GitHub Desktop.
Example for how to use CORS with Loggly's APIv2.
function basicAuth() {
return "Basic " + btoa("<username>:<password>");
};
$.ajax({
url: 'https://<subdomain>.loggly.com/apiv2/customer',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", basicAuth());
},
success: function(data) {
alert("SUCCESS");
console.log(data);
},
error: function() {
alert("FAIL");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment