Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:2 Changed 2 years ago by rwaldron
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 2 years ago by jitter
- Status changed from closed to reopened
- Resolution invalid deleted
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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.
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".