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 comment:1
component: | core → ajax |
---|---|
owner: | → yehuda |
status: | new → assigned |
Changed April 14, 2008 07:55PM UTC by comment:2
resolution: | → fixed |
---|---|
status: | assigned → closed |
Fixed in [5253].
Changed April 16, 2008 03:08AM UTC by 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 comment:4
resolution: | fixed |
---|---|
status: | closed → reopened |
Changed April 22, 2008 10:07PM UTC by comment:5
resolution: | → fixed |
---|---|
status: | reopened → closed |
Improved in [5281], added test.
Changed April 22, 2008 10:18PM UTC by comment:6
resolution: | fixed |
---|---|
status: | closed → reopened |
Changed April 22, 2008 10:19PM UTC by 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 comment:8
resolution: | → fixed |
---|---|
status: | reopened → closed |
Fixed in [5282].
Changed June 20, 2008 09:28PM UTC by comment:9
resolution: | fixed |
---|---|
status: | closed → reopened |
Changed June 20, 2008 09:29PM UTC by comment:10
resolution: | → duplicate |
---|---|
status: | reopened → closed |
On abort via beforeSend, ajaxStop is never called, even when ajaxStart was triggered.
Closing this ticket as duplicated of #2935, see patch there.
I am patching $.ajax to allow return false from beforeSend, as well as to pass the $.ajax options as the second parameter to beforeSend.