【发布时间】:2015-05-25 15:04:37
【问题描述】:
我正在尝试使用此验证器 https://github.com/1000hz/bootstrap-validator 进行客户端检查,然后允许 ajax 提交整个表单。我在文档中找不到示例,并且我当前的代码不起作用,它使用 GET 查询字符串的值重新加载整个页面。有什么想法吗?谢谢!
$('#send-form').validator().on('submit', function (e) {
if (e.isDefaultPrevented()) {
// handle the invalid form...
} else {
// everything looks good!
$.post( "/post/ajax",
$( "#send-form" ).serialize(),
function( data ) {
$( "#ajax-result" ).html( data );
});
}
});
【问题讨论】:
-
尝试在
if (e.isDefaultPrevented())上方添加e.preventDefault()?
标签: jquery ajax twitter-bootstrap