Skip to content

Instantly share code, notes, and snippets.

@waldyrfelix
Created October 30, 2012 22:10
Show Gist options
  • Save waldyrfelix/3983411 to your computer and use it in GitHub Desktop.
Save waldyrfelix/3983411 to your computer and use it in GitHub Desktop.
Requisição HTTP Basic Authorization com JS
$.ajax({
url: "http://localhost:36210/api/values",
type: "GET",
dataType: "json",
beforeSend: function(xhr){
xhr.setRequestHeader('Authorization', 'Basic d2FsZHlyOjEyMw==');
},
success: function(data) {
$(data).each(function(index, value){
console.log(index + ') '+ value);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment