I try to get access to a directory or file that is protected with .htaccess with this code:
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = btoa(tok);
return "Basic " + hash;
}
and
$.ajax
({
type: "GET",
url: "prot/index.php",
dataType: 'json',
async: false,
data: {username: username, password: password},
headers : { Authorization: make_base_auth(username, password) },
success: function (){
alert('geschafft');
},
error: function (xhr, ajaxOptions, thrownError){
console.log('Fehler: ' + thrownError+ "; status: " +xhr.status);
}
});
But I get the error:
SyntaxError: Unexpected end of input and the status 200
I also tried it with beforeSend and xhr.SetRequestHeader with the same result.
What's wrong ?