Bug Tracker

Ticket #2688 (closed enhancement: duplicate)

Opened 8 months ago

Last modified 6 months ago

beforeSend should be able to cancel the Ajax call

Reported by: yehuda Assigned to: yehuda
Type: enhancement Priority: major
Milestone: 1.2.4 Component: ajax
Version: 1.2.3 Keywords:
Cc: Needs: Commit

Description

There's no current way to stop an Ajax call based on certain criteria. For instance, it would be nice to be able to cache the results of Ajax calls, and have them fire the success function for subsequent calls after the first success.

Attachments

Change History

Changed 8 months ago by yehuda

  • owner set to yehuda
  • status changed from new to assigned
  • component changed from core to ajax

I am patching $.ajax to allow return false from beforeSend, as well as to pass the $.ajax options as the second parameter to beforeSend.

Changed 8 months ago by scott.gonzalez

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in [5253].

Changed 8 months ago by flesler

Hi Yehuda It's really an unnecesary change but... you could simply do:

if ( s.beforeSend && s.beforeSend(xml, s) === false )
	  return false;

Seems clearer to me, and it's shorter.

Changed 7 months ago by joern

  • status changed from closed to reopened
  • resolution deleted

Changed 7 months ago by joern

  • status changed from reopened to closed
  • resolution set to fixed

Improved in [5281], added test.

Changed 7 months ago by joern

  • status changed from closed to reopened
  • resolution deleted

Changed 7 months ago by joern

Turned out that $.ajax increased the active requests counter via jQuery.active++ without ever decreasing that when cancelling via beforeSend, preventing ajaxStop to get triggered when appropiate. Also the opened socket wasn't closed.

Changed 7 months ago by joern

  • status changed from reopened to closed
  • resolution set to fixed

Fixed in [5282].

Changed 6 months ago by joern

  • status changed from closed to reopened
  • resolution deleted

Changed 6 months ago by joern

  • status changed from reopened to closed
  • resolution set to duplicate

On abort via beforeSend, ajaxStop is never called, even when ajaxStart was triggered.

Closing this ticket as duplicated of #2935, see patch there.

Note: See TracTickets for help on using tickets.