Use http://jquery.malsup.com/form/. Here's how I do - this method handles the error (and other conditions) to stop animation. It can also either ajaxify form or submit it right away (depending on the submit flag), and do couple of other things.
function GenericAjaxForm(form, success, submit, beforeSubmit) {
var form = $(form);
var options = {
beforeSubmit: function(data, frm, options) {
form.disable(true);
form.find("input:submit:last").after(
"<span class='ajaxwait'><img src='../Content/images/smallwait.gif' /></span>");
if (beforeSubmit)
return beforeSubmit(data, frm, options);
},
error: function(xhr, status, error) {
$(".validation-summary-errors").html(getAjaxErrorMessage(status, xhr));
form.disable(false);
form.find(".ajaxwait").remove();
},
success: function(data) {
form.disable(false);
form.find(".ajaxwait").remove();
$(".validation-summary-errors").html('');
if (CheckValidationErrorResponse(data, form))
return;
success(data);
}
};
if (submit)
form.ajaxSubmit(options);
else
form.ajaxForm(options);
}