Couldn't set AcceptHeader when dataType = jsonp
The REST API I'm working with does not support "Accept */*" for JSONP requests.
That's why I try to override the header with:
- beforeSend: function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript")
}
or
- $.ajaxSetup({
accepts: "text/javascript"
});
This will stop working as soon as I set
- dataType: "jsonp"
as you can see here
- $.ajax({
url: url,
type: 'get',
beforeSend: function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript")
},
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("Something went wrong");
},
jsonpCallback: 'myCallback',
// contentType: 'application/json',
dataType: 'jsonp'
});
When I disable the param "dataType" the header gets set correctly but the callback will not be appended to the request and vice versa
Is there a solution for this ?
Maybe this is a bug in jQuery ?
Kind regards
Peter