问题遇到的现象和发生背景
无法关闭layui的弹出窗,如下图:
点击确定后,没有反应,修改学生信息这个窗口也没有关闭!
问题相关代码,请勿粘贴截图
修改按钮
<td class="td-manage">
<span title="查看" onclick="WeAdminShow('修改学生信息','${pageContext.request.contextPath}/admin/edit?stuid=${stu.studentId}')">
<span class="layui-btn layui-btn-normal layui-btn-xs">修改</span>
</span>
<span title="删除" onclick="member_del(this,${stu.studentId},${pageInfo.pageNum},${pageInfo.pages},${pageInfo.total},${pageInfo.pageSize})">
<span class="layui-btn layui-btn-danger layui-btn-xs">删除</span>
</span>
</td>
按钮调用的js函数
window.WeAdminShow = function (title, url, w, h) {
if (title == null || title == '') {
title = false;
};
if (url == null || url == '') {
url = "404.jsp";
};
if (w == null || w == '') {
w = ($(window).width() * 0.9);
};
if (h == null || h == '') {
h = ($(window).height() - 50);
};
layer.open({
type: 2,
area: [w + 'px', h + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
shade: 0.4,
title: title,
content: url
});
}
ajax请求
form.on('submit(check)', function (data) {
console.log("phone:" + data.field.phone);
var selectDormitroy = $("#dormitoryId").find('option:selected').val();
if (phone == data.field.phone && name == data.field.name && dormitoryId == selectDormitroy) {
layer.alert('没有修改,无需提交');
return ;
}
$.ajax({
url: result+"/admin/edit.do",
type: "post",
dataType: "json",
contentType: "application/json;charset=UTF-8",
async:true,
data: JSON.stringify({
"studentId":data.field.studentId,
"name":data.field.name,
"phone":data.field.phone,
"aftDormitoryId":selectDormitroy,
"buildingId": data.field.buildingId,
"preDormitoryId": dormitoryId,
}),
success: function (data) {
if (data.status == "1"){
layer.alert("修改成功",{icon:6},function () {
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
console.log(index);
parent.layer.close(index); //再执行关闭
});
}
},
error: function (jqXHR, textStatus, errorThorown) {
console.log("jqXHR:" + jqXHR);
console.log("textStatus:" + textStatus);
console.log("errorThorown:" + errorThorown);
}
});
return false;
});
运行结果及报错内容
我需要关闭修改学生信息这个窗口!