I am trying to make Jquery Ajax call to a REST Service.The service excepts Basic authentication which requires User Name & Password. So, while making the Ajax request i have added the Authorization tag in the code.But still i don't see the Authorization tag after the request.
var username = "user";
var password = "pwd";
var url = 'mysite.com';
$.ajax({
url: url,
success: function(json) {
alert("Success", json);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus, errorThrown);
},
//headers: {'Authorization': 'Basic bWFkaHNvbWUxMjM='},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
},
type: 'GET',
contentType: 'json',
});