0

I'm using this code to send my form using ajaxForm plugin

$('#donations').ajaxForm({
        dataType: 'json',
        beforeSubmit: function(){
            $('#message').html('');
            $('#submit').css('color', 'red').attr("disabled", true);
        },
        success: function(response) {
            if (response.status == 'success'){
                $('#donations').resetForm();
                $('#submit').css('color', 'white').removeAttr("disabled");
                $('#message').html(response.text).delay(5000).fadeOut();
            } else {
                $('#submit').css('color', 'white').removeAttr("disabled");
                $('#message').html(response.text).delay(5000).fadeOut();
            }
        }
    });

The submit button change and the message appear but the form don't reset. What's the problem?

4

1 回答 1

0

resetForm是一个选项没有功能

看看这个选项对象

布尔标志,指示如果提交成功,是否应重置表单

默认值:空

所以我认为您需要将代码更改为以下内容:

$('#donations').ajaxForm({
    dataType: 'json',
    resetForm: true
    //.........
});
于 2013-05-30T16:31:16.483 回答