验证工作完美。但是,验证通过后,屏幕将显示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();
}
});
答案 0 :(得分:0)
看看......
http://forum.jquery.com/topic/after-successful-validation-form-not-submitting
alano999的最新重播。希望它可以帮到你。