New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONP and parsing responseText upon 409 Conflict #4771
Comments
Thanks for the report. We considered #4379 to be a bug fix but JSONP is a bit special, indeed - under the hood it's a script but it simulates JSON responses in an environment without a CORS setup and sending JSON payloads on error responses is quite typical there. Maybe we need to revisit the JSONP case. It'd help if you could provide a minimal test case or - even better - a test case for the jQuery test suite, something like Lines 809 to 922 in 82b87f6
|
@mgol Thanks for the quick response. I will give it a try to make a test case or at the very least a minimal test case. I hope I correctly described the situation but will confirm for sure (bit complicated with Backbone, Server, and JQuery). |
It’d help if the test case didn’t contain external libraries. If this is
just about JSONP in error scenarios, any 4xx or 5xx status code should work
for the test case.
Thanks!
--
Michał Gołębiowski-Owczarek
|
Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special: under the hood it's a script but it simulates JSON responses in an environment without a CORS setup and sending JSON payloads on error responses is quite typical there. This commit makes JSONP error responses still execute the payload. The regular script error responses continue to be skipped. Fixes gh-4771 Closes gh-4773
Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special: under the hood it's a script but it simulates JSON responses in an environment without a CORS setup and sending JSON payloads on error responses is quite typical there. This commit makes JSONP error responses still execute the payload. The regular script error responses continue to be skipped. Fixes gh-4771 Closes gh-4773 (cherry picked from commit a1e619b)
Don't use a script tag for JSONP requests unless for cross-domain requests or if scriptAttrs are provided. This makes the `responseJSON` property available in JSONP error callbacks. This fixes a regression from jQuery 3.5.0 introduced in jquerygh-4379 which made erroneous script responses to not be executed to follow native behavior. The 3.x-stable branch doesn't need this fix as it doesn't use script tags for regular async requests. Ref jquerygh-4771 Ref jquerygh-4773 Ref jquerygh-4379
Don't use a script tag for JSONP requests unless for cross-domain requests or if scriptAttrs are provided. This makes the `responseJSON` property available in JSONP error callbacks. This fixes a regression from jQuery 3.5.0 introduced in gh-4379 which made erroneous script responses to not be executed to follow native behavior. The 3.x-stable branch doesn't need this fix as it doesn't use script tags for regular async requests. Closes gh-4778 Ref gh-4771 Ref gh-4773 Ref gh-4379
Bug Reports:
Unable to parse responseText of JSONP in a error handler.
Currently using Backbone and JQuery. Recently have upgraded from 3.3.1 to 3.5.1. Essentially, backbone is using a jsonp request to delete a model but expecting a 409 due to the model being unable to be deleted. It works as expected and end up in the error handler but the responseJson is not present. I have walked through the stack trace difference between 3.3.1 & 3.5.1. The reason seems to be a parsing error:
error: Error: jQuery35109401972421271656_1597775421415 was not called at Function.error (3.5.1/jquery.js:334:9) at s.converters.script json (3.5.1/jquery.js:10232:12) at ajaxConvert (jquery/3.5.1/jquery.js:9260:19) at done (3.5.1/jquery.js:9736:15) at XMLHttpRequest.<anonymous> (3.5.1/jquery.js:10047:9) message: "jQuery35109401972421271656_1597775421415 was not called" stack: "Error: jQuery35109401972421271656_1597775421415 was not called state: "parsererror"
From walking through the stacktrace it seems related to - 50871a5
The text was updated successfully, but these errors were encountered: