Skip to main content

Bug Tracker

Side navigation

#2688 closed enhancement (duplicate)

Opened April 14, 2008 06:08PM UTC

Closed June 20, 2008 09:29PM UTC

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.

Attachments (0)
Change History (10)

Changed April 14, 2008 06:08PM UTC by yehuda comment:1

component: coreajax
owner: → 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.

Changed April 14, 2008 07:55PM UTC by scott.gonzal comment:2

resolution: → fixed
status: assignedclosed

Fixed in [5253].

Changed April 16, 2008 03:08AM UTC by flesler comment:3

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 April 22, 2008 10:07PM UTC by joern comment:4

resolution: fixed
status: closedreopened

Changed April 22, 2008 10:07PM UTC by joern comment:5

resolution: → fixed
status: reopenedclosed

Improved in [5281], added test.

Changed April 22, 2008 10:18PM UTC by joern comment:6

resolution: fixed
status: closedreopened

Changed April 22, 2008 10:19PM UTC by joern comment:7

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 April 22, 2008 10:19PM UTC by joern comment:8

resolution: → fixed
status: reopenedclosed

Fixed in [5282].

Changed June 20, 2008 09:28PM UTC by joern comment:9

resolution: fixed
status: closedreopened

Changed June 20, 2008 09:29PM UTC by joern comment:10

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.