Jquery:成功验证后提交表单

时间:2013-06-23 15:50:09

标签: jquery

验证工作完美。但是,验证通过后,屏幕将显示JSON消息,并且不会重定向到/settings/branch。没有验证代码,它可以很好地工作,重定向和所有。

$("#JqAjaxForm").validate({
    rules: {
        branch_name: {
            minlength: 2,
            required: true
        },
        version: {
            required: true,
            minlength: 2,
        },
    },
    highlight: function(element) {
        $(element).closest('.control-group').removeClass('success').addClass('error');
    },
    success: function(element) {
        element
        .addClass('valid')
        .closest('.control-group').removeClass('error').addClass('success');
    },

    submitHandler: function(form) {
        //e.preventDefault();
        dataString = $(form).serialize();
        $.ajax({
            type: "POST",
            url: "/settings/branch",
            data: dataString,
            dataType: "json",
            success: function(data) {
                clearForm(form);

                if(data.field_check){
                    window.location.href = "/settings/branch/";
                } else {
                    $("#message_ajax").html("<div class='alert alert-error fade in'>" + data.message + "</div>");

                    }
                }
            });
            //form.submit();
            $(form).ajaxSubmit();
        }
    });

1 个答案:

答案 0 :(得分:0)

看看......

http://forum.jquery.com/topic/after-successful-validation-form-not-submitting

alano999的最新重播。希望它可以帮到你。