Opened 8 years ago
Closed 8 years ago
#32628 closed task (blessed) (fixed)
Allow wp.ajax.send() requests to be stopped via abort()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | General | Keywords: | has-patch commit |
Focuses: | javascript | Cc: |
Description
For Menu Customizer (#32576) we have a search box that triggers after a delay triggers an Ajax request via wp.ajax.post()
. The promise
that this returns has done()
, fail()
, and always()
handlers added to it. We want the done()
to not happen if the user starts typing again and another Ajax request is initiated. In jQuery's Ajax API, the jqXHR has an abort()
method which stops the HTTP request and causes the fail()
to execute. However, in the wp.ajax.send()
(and wp.ajax.post()
) wrappers around jqXHR, this abort()
method is not made available, and so there is no way to stop a WP Ajax request presently. I propose we add the abort()
method. This was given the thumbs up: https://wordpress.slack.com/archives/core/p1433964230002347
Attachments (1)
Change History (4)
#2
@
8 years ago
this is fine, I changed the naming case to match jQuery:
https://github.com/jquery/jquery/search?utf8=%E2%9C%93&q=xhr&type=Code
I'll commit this.
Source: https://github.com/xwp/wordpress-develop/commit/09c0d2489e961c2691a6d2748645a8a6ac673c58