Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#7694 closed bug (duplicate)

JSONP doesn't use Accept-Header application/json

Reported by: 3stan@… Owned by:
Priority: undecided Milestone: 1.6
Component: ajax Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

If using $.getJSON() or $.ajax() with datatype jsonp or with datatype json and callback=? in the url, the Accept Header of the request is set to */* instead of application/json.

In my case this forces the REST server to respond with application/xml.

The same problem was issued in Ticket #6551, but it was set to invalid. I think this is a valid bug. So I create a new ticket for this.

Change History (5)

comment:1 Changed 8 years ago by jitter

Resolution: invalid
Status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report. After checking your report and making up a live test case I came to the conclusion that this is not a bug.

If you check the documentation on jQuery.ajax() you will find several statements related to jsonp but I guess this one should explain what happens.

When data is retrieved from remote servers (which is only possible using the script or jsonp data types), the operation is performed using a <script> tag rather than an XMLHttpRequest object.

Because of the same origin policy it isn't possible to use XMLHttpRequest to make a cross-domain jsonp request instead the solution described above is used. This naturally means that jQuery can't possibly influence the accept header as loading the <script> is handled by the browser. In FF and Chrome thus you will see */* as accept header value. So this is a bug on the REST server which should know that request to a certain URL in a certain format should mean "RETURN JSONP".

comment:2 Changed 8 years ago by Rick Waldron

Additionally, the correct way to address a bug that has been closed is to post a re-open request ON THAT TICKET with a valid, reduced test case. #6551

comment:3 Changed 8 years ago by jitter

Resolution: invalid
Status: closedreopened

comment:4 Changed 8 years ago by jitter

Component: unfiledajax
Resolution: duplicate
Status: reopenedclosed

comment:5 Changed 8 years ago by jitter

Duplicate of #6551.

Note: See TracTickets for help on using tickets.