Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32628 closed task (blessed) (fixed)

Allow wp.ajax.send() requests to be stopped via abort()

Reported by: westonruter's profile westonruter Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 3.6
Component: General Keywords: has-patch commit
Focuses: javascript Cc:


For Menu Customizer (#32576) we have a search box that triggers after a delay triggers an Ajax request via 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 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:

Attachments (1)

Change History (4)

#1 @westonruter
9 years ago

  • Keywords commit added

#2 @wonderboymusic
9 years ago

this is fine, I changed the naming case to match jQuery:

I'll commit this.

#3 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 32747:

Add an abort class method to the Promise instance returned by wp.ajax.send().

Props westonruter.
Fixes #32628.

Note: See TracTickets for help on using tickets.