Ticket #10256 (closed bug: invalid)
Cross domain requests using jsonp
| Reported by: | stanislav | Owned by: | stanislav |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | ajax | Version: | 1.6.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When you perform a cross-domain jsonp request using jquery and if the server returns the jsonp response using status code != 200 you have the following:
- the registered error callback function tells you that status code is 200
- jquery is unable to parse jsonp - parseerror
The bellow http responses demonstrate the mentioned behavior. The first one is processed correctly instead of the second one.
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 211
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 12 Sep 2011 15:27:42 GMT
jQuery16306215030491174232_1315841261014({"initData":"bla-bla"})
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Length: 169
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 12 Sep 2011 16:49:55 GMT
jQuery16309673461931202953_1315846180861({"error":"Bla-bla"})
Change History
comment:2 Changed 21 months ago by rwaldron
- Owner set to stanislav
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to ajax
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.
comment:3 Changed 21 months ago by stanislav
- Status changed from pending to new
I've simply forgot to add: I've got this behavior in IE9 (haven't tested in other browsers yet)
comment:4 Changed 20 months ago by rwaldron
- Status changed from new to pending
Please provide a reduced test case
comment:5 Changed 20 months ago by stanislav
- Status changed from pending to new
Hello, The test could be found here http://jsfiddle.net/F7D7U/6/ Here is some explanation http://clip2net.com/s/1bJGO I'm not really sure that it is an issue at all, but I haven't found any documentation which tells that we can't use status codes <> 200 within jasonp requests. In IE 9 it invokes error callback with textStatus = 'parsererror'
comment:6 Changed 20 months ago by ajpiano
- Status changed from new to closed
- Resolution set to invalid
From the jQuery.ajax docs
error(jqXHR, textStatus, errorThrown)Function A function to be called if the request fails. ...'Note: This handler is not called for cross-domain script and JSONP requests.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I suppose that the main issue is that jquery doesn't process jsonp correctly in the case of StatusCode != 200.