I am running an ajax call to get some Data from an API. The call itself works fine, I get 200 (OK) as a response. Also I can See the JSON Data in my Dev Tools. But in the end the alert is "error" and the I have a "Uncaught SyntaxError: Unexpected token :" in my Console.
What going wrong there?
$.ajax({
url: 'my url',
type:'GET',
xhrFields: {
withCredentials: true
},
cache: false,
dataType: 'jsonp',
contentType: 'application/x-www-form-urlencoded',
// headers: {
// 'Authorization': 'Basic ' + btoa('uberall:cat-aspirin-window-cake')
// },
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pw));
},
success: function(text) { alert('success'); },
error: function (text) { alert('error'); },
complete: function(text) { alert('complete'); }
});