Bug Tracker

Modify

Ticket #7461 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

$.ajax(this) no longer allows "retries".

Reported by: mark@… Owned by: jaubourg
Priority: high Milestone: 1.5
Component: ajax Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by rwaldron

  • Owner set to mark@…
  • Status changed from new to pending
  • Component changed from unfiled to ajax
  • Milestone 1.5 deleted

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!

comment:2 Changed 3 years ago by jitter

 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 3 years ago by dmethvin

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 3 years ago by jitter

  • Keywords needstest added
  • Priority changed from undecided to high
  • Version changed from 1.4.3 to 1.4.4
  • Status changed from pending to open
  • Milestone set to 1.5

comment:5 Changed 3 years ago by rwaldron

  • Keywords needstest,ajaxrewrite added; needstest removed

comment:6 Changed 3 years ago by jaubourg

  • Owner changed from mark@… to jaubourg
  • Status changed from open to 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 3 years ago by jaubourg

  • Status changed from assigned to closed
  • Resolution set to fixed

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 3 years ago by aleonard1@…

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 in reply to: ↑ 8 Changed 3 years ago by anonymous

Replying to aleonard1@…:

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 3 years ago by jitter

  • Keywords needstest,ajaxrewrite removed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.