1.通过ajax方法传值
- 判断是否为空,不为空就弹出确定、取消的弹出层
function doSubmitForm() {
var gjc = document.getElementById("gjc").value;
var yzdm = document.getElementById("yzdm").value;
if (gjc.trim() == "") {
//空值校验弹提示窗
layer.msg(请填写检测词组,{
icon : 2,
time : 2000,
anim: 6
}
);
return false;
}
layer.confirm(是否提交监测词组?,{
offset: 100px}, function() {
//提交按钮确认弹窗
var params= $("form").serialize();//选择表单元素
console.log(params);
$.ajax({
url:"sjjcinsertout.action", //跳转action:
type:"post",
data: params,
dataType:"text",
success:function(data){
//加载刷新页面并关闭弹窗
/* window.parent.location.reload();
parent.layer.closeAll(iframe); */
var index2 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index2);
alert("监测词组插入成功");
/* var index2 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index2); */
},
error:function(xhr){
alert(xhr.status)
}
});
2.通过自带的layer.open请求action
<input class="layui-btn layui-btn-normal"
style=" color:white;background-color: #7ED321;text-decoration : none"
value="审核通过" onclick="sh_passview()" />
<script>
//编辑弹出框,跳转action:sjxxupdatein,传值sjbh事件代码
function sh_passview() {
layer.open({
type : 2,
title : 审核通过,
maxmin : false,
shadeClose : true, //点击遮罩关闭层
shade : 0.4,
scrollbar : true,
area : [ 80%, 60% ],
content : add_viewAction?yqbh=+yqbh,
offset : 100px
});
}
</script>