【发布时间】:2017-05-10 02:29:53
【问题描述】:
我正在尝试使用 ajaxForm 插件通过 ajax 提交表单。我遇到的问题是我需要提交两次表格才能实际提交表格。请参阅下面的代码,感谢您的帮助。
$(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>
我尝试将其更改为 ajaxSubmit 然后添加 e.preventDefault();但是当我尝试时,表单根本没有提交。
【问题讨论】:
标签: submit ajaxform ajaxsubmit