What I did was attach to the beforeSend event of the form, save the xhr object as part of the form data and abort it if a new request is in the queue:
$('form').bind("ajax:beforeSend", function(evt, xhr) {
console.log('Enqueued new xhr request');
var prevXhr = $(this).data('current-xhr');
if (prevXhr) {
prevXhr.abort();
console.log('Aborting previous xhr request');
}
$(this).data('current-xhr', xhr);
});
And you can still use the option :remote => truein the form.
source
share