With standard AJAX, I can cancel a request-in-progress by using xhr.abort():

var xhr = new XMLHttpRequest();
// set up my xhr
// etc...

// Later: realize I don't want the response after all...

Is there any way to do this with actionFunctions?

My use case is a complex search interface where the request-response-rerender circuit can take several seconds. We've decided not to disable the search interface during the query, so it's possible for a user to realize they want to refine their criteria and requery. So in the query function, I want to check whether there's already a request in process, cancel it if there is, and send a new one. Here's the simplified concept:

<apex:actionFunction name="doSearch" value="{!doSearch}">
    <apex:param name="myParams" assignTo="{!queryParams}" value=""/>

function prepareQuery() {
     // grab values from the search form, client-side validation, etc.
     // if we're going to query:


  • If I had to guess, apex:actionFunction doesn't automatically execute XMLHttpRequest functions. Most action calls perform an HTTP post, unless they are using the reRender action, which hooks into the AJAX partial page refresh functionality of the VF page. I've not actually cracked this open to understand, this is just what I suspect based on observation. And if that's the case, you'll have nothing to abort.
    – pchittum
    Jan 22, 2013 at 16:14
  • Interesting. I guess the question would be, "can I interrupt VF to prevent the rerendering." Will take more digging at some point...
    – Benj
    Jan 22, 2013 at 18:50

1 Answer 1


I would try with timeout param of actionFunction:

<apex:actionFunction timeout="500" />

After 30 secs the actionFunction will be cancelled (timeouted) automatically.

The amount of time (in milliseconds) before an AJAX update request should time out.


  • Thanks @Mastor, but I'm not trying to cancel automatically. If the conditions merit cancelling, I want to cancel even w/in a specified timeframe. And if I'm not cancelling, the whole request may need a couple seconds to succeed.
    – Benj
    Jan 21, 2013 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .