Skip to content

Instantly share code, notes, and snippets.

@fadamakis
Last active December 17, 2015 20:39
Show Gist options
  • Save fadamakis/5668829 to your computer and use it in GitHub Desktop.
Save fadamakis/5668829 to your computer and use it in GitHub Desktop.
$.ajax({
type:"GET",
url:baseurl,
beforeSend:function (xhr) {
var creds = username + ":" + password;
var basicScheme = btoa(creds);
var hashStr = "Basic " + basicScheme;
xhr.setRequestHeader('Authorization', hashStr);
xhr.setRequestHeader('accept', 'application/json');
},
success:function (data) {
//success stuff
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment