我有这个用 jQuery 验证插件编写的 AJAX 提交表单。这一切都很完美,但我注意到人们在脚本完成之前重新提交表单,这导致我们的数据库中出现重复记录。这是我到目前为止的代码:
$(document).ready(function(){
$("#myform").validate({
    debug: false,
    rules: {
        fname: {required: true}, 
        sname: {required: true}, 
        sex: {required: true}, 
    },
    messages: {
        fname: {required: "- Field required."},
        sname: {required: "- Field required."},
        sex: {required: "- Field required."},
    },
    errorPlacement: function(error, element) {
        if ( element.is(":radio") ) {
        error.appendTo('.radioError');
        }
        else {
        error.insertAfter( element );
        }
    },
    submitHandler: function(form) {
        $.post('process_participant.php', $("#myform").serialize(), function(data) {
            $('#results').html(data);
        });
        }
    });
});
谁能向我解释如何扩充此代码以将加载 gif 放入我的结果 div 直到我的脚本完成并且加载 gif 被我的实际结果替换?我认为这会阻止人们双击提交按钮。