今天工作有个需求layui弹出框的表单提交后,关闭当前的弹出框,并且刷新父iframe页面。在网上找了许多资料才找到,记录一下:
$.ajax({
async: false,
type: "POST",
url:'',
headers: {
'Authorization':token
},
dataType: "json",
data: {
},
success: function(res) {
if(res.code=='SUCCESS'){
alert(res.msg);
}else if(res.code=='BIZ_EXCEPTION'){
alert(res.msg);
}
window.parent.location.reload();//刷新父页面
var index = parent.layer.getFrameIndex(window.name);//获取当前iframe层的索引
parent.layer.close(index);//执行关闭
}
});