Couldn't set AcceptHeader when dataType = jsonp

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:
  1. beforeSend: function(xhr) {
                xhr.setRequestHeader("Accept", "text/javascript")
    }

      or
  1. $.ajaxSetup({
          accepts: "text/javascript"
        });  


This will stop working as soon as I set
  1. dataType: "jsonp"
as you can see here
  1. $.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











    • Topic Participants

    • info