Bug Tracker

Opened 12 years ago

Closed 11 years ago

#2688 closed enhancement (duplicate)

beforeSend should be able to cancel the Ajax call

Reported by: yehuda Owned by: yehuda
Priority: major Milestone: 1.2.4
Component: ajax Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:

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.

Change History (10)

comment:1 Changed 12 years ago by yehuda

Component: coreajax
Owner: set to yehuda
Status: newassigned

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

comment:2 Changed 12 years ago by scott.gonzal

Resolution: fixed
Status: assignedclosed

Fixed in [5253].

comment:3 Changed 12 years 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.

comment:4 Changed 12 years ago by joern

Resolution: fixed
Status: closedreopened

comment:5 Changed 12 years ago by joern

Resolution: fixed
Status: reopenedclosed

Improved in [5281], added test.

comment:6 Changed 12 years ago by joern

Resolution: fixed
Status: closedreopened

comment:7 Changed 12 years 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.

comment:8 Changed 12 years ago by joern

Resolution: fixed
Status: reopenedclosed

Fixed in [5282].

comment:9 Changed 11 years ago by joern

Resolution: fixed
Status: closedreopened

comment:10 Changed 11 years ago by joern

Resolution: duplicate
Status: reopenedclosed

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.