一、页面响应接口报错
将@Controller改成@RestController
二、layui提交数据后关闭子页面
layer.msg(data.msg, {icon:1,time:3000}, function(){
var index = parent.layer.getFrameIndex(window.name);
parent.location.reload(); //刷新父页面
parent.layer.close(index);
});
//提交事件
form.on('submit(demo1)', function (data) {
alert(JSON.stringify(data.field), {
title: '最终的提交信息'
}),
$.ajax({
url: data.form.action, //提交请求的URL
type: "post", //请求方式get,post,put,delete等
dataType: 'json'
,contentType: 'application/json;charset=utf-8'
,data: JSON.stringify(data.field), //提交的表单数据
success: function (result) {
if (result.success) {
layer.msg(result.msg, {icon: 1, time: 2000, title: '成功'}) //返回数据成功时弹框
} else {
layer.msg(result.msg, {icon: 2, time: 2000, title: '失败'}) //返回数据失败时弹框
}
},
error: function (result) {
alert("接口错误!!!"); //无返回或处理有报错时弹框
}
});
alert("添加成功")
layer.msg(data.msg, {icon:1,time:3000}, function(){
var index = parent.layer.getFrameIndex(window.name);
parent.location.reload(); //刷新父页面
parent.layer.close(index);
});
return false;
});