Opened 15 years ago
Closed 15 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 15 years ago by
Component: | core → ajax |
---|---|
Owner: | set to yehuda |
Status: | new → assigned |
comment:3 Changed 15 years ago by
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 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Improved in [5281], added test.
comment:6 Changed 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:7 Changed 15 years ago by
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:9 Changed 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:10 Changed 15 years ago by
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.