-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Ajax: Execute JSONP error script responses #4773
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
Conversation
However, it should not parse the response if just a script
Thanks for opening a PR. Is there an issue already open to go with this? |
Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! This is a very good start. I added some comments.
Need a before send to allow the error to take place
It looks like it should be passing
Please sign our CLA, we can't merge the PR without that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
@mgol Thanks for the approving it. Any idea on how long it will take before the next release of jQuery? I am just wondering whether will need to patch in before the company next release cycle. |
@fras2560 we don’t have a fixed release schedule & a lot depends on how fast we fix other issues in the 3.6.0 milestone. But unless we get PRs for most of those issues, I’d assume it may take a few months. |
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)
The new test failed on master, |
From what I see, JSONP error responses have never been passed to the error callback for cross domain requests. So we can probably leave it as-is on |
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
Fix for |
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
Fixes: #4771
However, it should not parse the response if just a script