#7461 closed bug (fixed)
$.ajax(this) no longer allows "retries".
Reported by: | Owned by: | jaubourg | |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | ajax | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In JQ 1.4.2, you can send an ajax request, and on error, resend it using $.ajax(this) as per "Defensive Ajax" article: http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery
In 1.4.3, I get recursion errors.
Change History (10)
comment:1 Changed 12 years ago by
Component: | unfiled → ajax |
---|---|
Milestone: | 1.5 |
Owner: | set to [email protected]… |
Status: | new → pending |
comment:2 Changed 12 years ago by
test case with workaround. Including this.context = undefined;
in the error handler before reissuing the ajax request works around the problem. Take it out and after the first ajax request it fails with max recursion exception.
This happens when jQuery on this line tries to merge ajaxSettings
with the ones passed in from the retry in the error handler. But as origSettings === origSettings.context === origSettings.context.context === ....
the deep copy won't stop.
This recursive dependency is caused on this line when in the original ajax request no context
was provided it becomes s.context = s
. Seems to have been introduced with the rewrites in #dcf0fa
comment:3 Changed 12 years ago by
I like the elegance of retrying with $.ajax(this); if we're supporting it the unit tests should definitely have an explicit case for it.
Relatedly, some people have asked for the ability to specify the .context in $.ajaxSettings, which currently can't be done.
comment:4 Changed 12 years ago by
Keywords: | needstest added |
---|---|
Milestone: | → 1.5 |
Priority: | undecided → high |
Status: | pending → open |
Version: | 1.4.3 → 1.4.4 |
comment:5 Changed 12 years ago by
Keywords: | ajaxrewrite added |
---|
comment:6 Changed 12 years ago by
Owner: | changed from [email protected]… to jaubourg |
---|---|
Status: | open → assigned |
dmethvin: could be a good idea to open a feature request for setting context in ajaxSettings so that we can discuss this specific issue separately (unless the request already exists in the system, of course).
comment:7 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Added a test for retrying a request on error using jQuery.ajax(this). Works as intended. Fixes #7461.
Changeset: 63487505c678152e59847e3ab7878ea5f2514dfa
comment:8 follow-up: 9 Changed 12 years ago by
Please pardon me for my ignorance, but does that mean the bug will be fixed in the next version (the unit test having been written for developing 1.5), or are you saying it works as intended now? Because I am still getting errors.
comment:9 Changed 12 years ago by
Replying to [email protected]…:
Please pardon me for my ignorance, but does that mean the bug will be fixed in the next version (the unit test having been written for developing 1.5), or are you saying it works as intended now? Because I am still getting errors.
Never mind, I see it's mentioned as fixed in the 1.5 beta 1 patch notes. :)
comment:10 Changed 12 years ago by
Keywords: | needstest ajaxrewrite removed |
---|
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!