I am trying to make an ajax call for the baic authentication using the following code -
$.ajax({
method: "GET",
xhrFields: {
"withCredentials": true
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic c2h1YmhhbS5hLmFncmF3YWw6U1VOSUxANzYwMg==');
xhr.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
},
url: //some url,
dataType: "jsonp",
success: function (res) {
alert("SUCC");
},
error: function (err) {
console.log(err);
alert(err.status);
}
});
But everytime it thorows the error Uncaught SyntaxError: Unexpected token < and goes to the error function.
Couldn't figure out the problem....plz help....very important.!!!
Regards, Shubham Agrawal