With standard AJAX, I can cancel a request-in-progress by using xhr.abort():
var xhr = new XMLHttpRequest();
// set up my xhr
// etc...
xhr.send();
// Later: realize I don't want the response after all...
xhr.abort();
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=""/>
</apex:actionFunction>
<script>
function prepareQuery() {
// grab values from the search form, client-side validation, etc.
// if we're going to query:
someWayToCancelPreviousQuery();
doSearch(myParams);
}
</script>
Thanks!