0

验证工作完美。但是,当验证通过时,屏幕会显示 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();
        }
    });
4

1 回答 1

0

看一看...

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

alano999 的最新回放。希望它可以帮助你。

于 2013-07-29T19:19:17.557 回答