如你点击编辑按钮,弹出编辑信息,但是你需要判断当前记录是否存在或已删除,如果异常,就关闭此弹出层,然后提示错误信息
window.initData = function(){
$.ajax({
url:httpUrl+‘xxx’,
data:{
“id”:dataId
},
async:false,
method:“post”,
dataType:‘json’,
success:function(result){
if(result.status == “success”){
cidDo = result.data.cid;
initCustomerLevel();
initOutAndInOutChannel();
form.val(‘editForm’,{
“cid”:result.data.cid,
“cidLevel”:result.data.cidLevel,
“channel”:result.data.channel
});
form.render();
}else{
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.layer.alert(result.message,{icon:1});
}
},
error:function(xhr){
console.log(xhr);
}
});
}
// 此代码
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.layer.alert(result.message,{icon:1});