#7868 closed bug (fixed)
AJAX error handler doesn't get access to the responseText, regression
Reported by: | Owned by: | jaubourg | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.5 |
Component: | ajax | Version: | git |
Keywords: | regression | Cc: | |
Blocked by: | Blocking: |
Description
In 1.4.2 I get an error callback on a 400 that includes the xhr with a populated responseText that I can parse and display as an error. In GIT the responseText is filtered out early on in the error handling code at a higher level and is not passed down to the error handler.
For example:
api.followbag = function(p, follower, following, success, failure) { var z = p.crumb, r = p.render; $.ajax({ url: '/v1/follow/' + follower + '/follows/bag/' + following + '?crumb=' + z + '' + (r ? '&render=' + r : '') + '', type: 'POST', dataType: "json", success: function(d) { if (success) success(d); }, error: function(xhr) { if (failure) failure($.parseJSON(xhr.responseText)); } }); };
The error function doesn't get passed the responseText and therefore cannot pass on the error information to the rest of the program.
Change History (11)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Component: | unfiled → ajax |
---|---|
Keywords: | regression added |
Milestone: | 1.next → 1.5 |
Owner: | set to jaubourg |
Priority: | undecided → blocker |
Status: | new → assigned |
comment:3 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixes #7868. ResponseText is now properly propagated for error callbacks.
Changeset: d515068ee807efef29b6c8406171be4725d7154f
comment:4 follow-up: 5 Changed 13 years ago by
Guys,
I'm running jquery 1.5 and I'm seeing this issue. I have jq talking to jersey jax-rs and if I return json from jersey with an http 400, xhr.responseText is empty. If I return the same json from jersey with a 200, xhr.responseText is present and correct.
I've tested in firefox and chrome and the behaviour is the same.
I've also tested the http call using curl and from curl I can see the response body.
comment:5 Changed 13 years ago by
Replying to luke.biddell@…:
Guys,
I'm running jquery 1.5 and I'm seeing this issue. I have jq talking to jersey jax-rs and if I return json from jersey with an http 400, xhr.responseText is empty. If I return the same json from jersey with a 200, xhr.responseText is present and correct.
I've tested in firefox and chrome and the behaviour is the same.
I've also tested the http call using curl and from curl I can see the response body.
Please submit a reduced test case, which reproduces the issue you are experiencing, on http://jsfiddle.net. So that we can investigate this issue further. Also make sure to read the link given below, in order to provide a most useful bug report.
comment:6 Changed 12 years ago by
i'm experiencing the same issue with jquery 1.5.
Can you explain how did you fixed this bug and how to use the responseText when 400 error code is send ?
Thanks
comment:8 follow-up: 9 Changed 12 years ago by
http://jsfiddle.net/RTvQQ/ is working in chrome.
My only guess is that you're trying on a browser that does not support cross-domain requests.
comment:9 Changed 12 years ago by
Replying to jaubourg:
My only guess is that you're trying on a browser that does not support cross-domain requests.
it's working for the success 200 status code but not in errors. i'm using Mozilla firefox 3.6.22 for Ubuntu
comment:10 Changed 12 years ago by
I have the same problem - when the response code is 400, xhr.responseText is empty on Firefox 3.6.23. In chrome this works fine. FF 3.6 does support cross domain requests.
If i change response code to 200, xhr.responseText is not empty on FF 3.6.
comment:11 Changed 12 years ago by
in firefox 3.6 xhr.status is not populated when http response is 400. In chrome xhr.status is populated when 400.
I'm pretty sure this is the offending code:
lines 7261-7269
I have no idea why it is filtering out the data and not passing it on to the handler.