You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSONP and parsing responseText upon 409 Conflict #4771
Bug Reports:
Unable to parse responseText of JSONP in a error handler.
What do you expect to happen? Able to parse the JSON
What actually happens? Get a parsing error
Which browsers are affected - Chrome/Firefox?
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
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
@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
@mgol I think I have fix for the issue and wrote up a simple test. However, I am not too familar with PHP so I might need some help with this. I am not even sure how to run it locally. Also, need some help with response body
Activity
mgol commentedon Aug 18, 2020
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
jquery/test/unit/ajax.js
Lines 809 to 922 in 82b87f6
fras2560 commentedon Aug 18, 2020
@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).
mgol commentedon Aug 18, 2020
fras2560 commentedon Aug 20, 2020
@mgol I think I have fix for the issue and wrote up a simple test. However, I am not too familar with PHP so I might need some help with this. I am not even sure how to run it locally. Also, need some help with response body
#4773
Ajax: Execute JSONP error script responses
Ajax: Execute JSONP error script responses
Ajax: Make responseJSON work for erroneous same-domain JSONP requests
Ajax: Make responseJSON work for erroneous same-domain JSONP requests