weixin_33712987 2016-12-19 19:34 采纳率: 0%
浏览 42

提交时隐藏表格

I have the following function:

var form = $('#review-contact-form');
form.submit(function(event){
    event.preventDefault();
    var form_status = $('<div class="form_status center"></div>');
    $.ajax({
        type: "POST",
        url: $(this).attr('action'),
        data: form.serialize(),
        beforeSend: function(){
            form.prepend(
                form_status
                    .html('<p><i class="fa fa-spinner fa-spin"></i> Sending...</p>')
                    .fadeIn()
            );
        }
    }).done(function(data){
        form_status
            .html('<p class="text-success">Thanks!</p>')
            .delay(3000)
            .fadeOut();
    });
});

Is there a way to hide the form when mail is sent?

  • 写回答

2条回答 默认 最新

  • weixin_33747129 2016-12-19 19:37
    关注

    form.hide(); after your form_status in done function.

    NOTE: I added this as answer because I cannot add comments

    评论

报告相同问题?