加入这个函数 给提交按钮添加button--pipalu这个class即可调用
/**
* 通用表单提交(AJAX方式)
*/
$('form').on('click','.button--pipalu',
function
() {
//alert('1');
$.ajax({
url: $(this).parents('form').attr('action'),
type: $(this).parents('form').attr('method'),
data: $(this).parents('form').serialize(),
success:
function
(info) {
if
(info.code === 1) {
setTimeout(function
() {
location.href = info.url;
}, 1000);
}
layer.msg(info.msg);
}
});
return false;
});

本文介绍了一种通过AJAX实现的通用表单提交方法,该方法可通过为提交按钮添加特定类来触发。具体实现包括使用jQuery监听表单提交事件,并通过AJAX发送表单数据。
1241

被折叠的 条评论
为什么被折叠?



