I am trying to use the ajaxForm plugin to submit a form via ajax. The problem I am having is that I need to submit the form twice to actually get the form to submit. See code below, and I appreciate any help.
$(document).on('click', 'button.submit-btn', function () {
alert('Please wait...');
setTimeout(function() {
$('button.submit-btn').attr('disabled', true);
}, 50)
$('#send-form').ajaxForm(function() {
var currentAlert = $.jAlert('current');
currentAlert.closeAlert();
successAlert('Success!', 'The form has been submitted');
$('button.submit-btn').attr('disabled', false);
});
});
<form action="" method="post" id="send-form">
<button type="submit" class="submit-btn" name="send-modal-form" value="submit"></button>
</form>
I tried to change it to ajaxSubmit and then add e.preventDefault(); but then the form doesn't submit at all when I try.