layui表单提交封装

 

/**
* 表单提交
* @param formId
* @param submitForm_success
* @return
*/
function submitForm(formId,submitForm_success){
layui.use('form', function(){
var form = layui.form;
//监听提交  ajaxSubmit.js支持
form.on('submit(formSubmit)', function(data){
$(formId).ajaxSubmit({
type:'post',
success:submitForm_success
});
return false;
});
});
}

submitForm("#addform",function(data){
data = JSON.parse(data);
parent.layer.msg(data.msg);
if(data.result=="success"){
parent.loadCount();
closeIframe();
}
});

posted @ 2019-08-22 11:55  小农_码  阅读(1218)  评论(0编辑  收藏  举报