I'm making a website that connects to different servers to request data. On each server I have to authenticate myself, I do it this way.
$.ajax({
dataType: 'jsonp',
async: false,
xhrFields: {
withCredentials: true
},
url: "http://servidor_01:8080?id=capota",
beforeSend: function (xhr) {
xhr.setRequestHeader ('Authorization', 'Basic ' + btoa('user:pass'));
},
});
The problem I have is that it does not accept the user and the password, I get the typical authentication window.