doumao1519 2017-02-16 07:30
浏览 423

jquery中的submitHandler()验证方法需要时间来执行和提交表单

I am using the jquery validate method to validate my form, I have written some code in submitHandler() method, However it taking time to execute. Please suggest me solution to overcome this issue.

$('#form').validate({
     submitHandler:function(form) {
           $('#loader').show();
           $('#btnsubmit').hide();
           $('#form').submit();
     }
});

This code taking time to hide the button and submit the form, Suggest me the solution to overcome this issue.

Thanks in Advance!!!

  • 写回答

1条回答 默认 最新

  • 普通网友 2017-02-16 12:10
    关注

    You could try enabling debug option to know why is taking time to execute, and with another event do the show hide logic. For example:

    // show hide logic
    $('#form #btnsubmit').click(function(e){
        $('#loader').show();
        $('#btnsubmit').hide();
    })
    
    $('#form').validate({
        // for debugging
        debug: true,
        submitHandler:function(form) {
           $('#form').submit();
        }
    });
    
    评论

报告相同问题?