Side navigation
#7694 closed bug (duplicate)
Opened December 03, 2010 02:48PM UTC
Closed December 03, 2010 03:37PM UTC
Last modified March 13, 2012 09:39PM UTC
JSONP doesn't use Accept-Header application/json
Reported by: | 3stan@3stan.net | 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.
Attachments (0)
Change History (5)
Changed December 03, 2010 03:32PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed December 03, 2010 03:34PM UTC by comment:2
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
Changed December 03, 2010 03:36PM UTC by comment:3
resolution: | invalid |
---|---|
status: | closed → reopened |
Changed December 03, 2010 03:37PM UTC by comment:4
component: | unfiled → ajax |
---|---|
resolution: | → duplicate |
status: | reopened → closed |
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
orjsonp
data types), the operation is performed using a<script>
tag rather than anXMLHttpRequest
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".