layui中的弹出层以及刷新
$.ajax({
url:url,
method:‘get’,
data:data.field,
dataType:‘json’,
async:true,
success:function (res) {
var obj = JSON.parse(res);
//添加失败
if (obj.code==0){
layer.open({
title: '提示'
,content: obj.message,
btn:['确定','取消'],
yes:function () {
//确定按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
},
btn2:function(){
//取消按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
},
cancel:function(){
//×按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
}
});
}else if (obj.code==1){
layer.open({
title: '提示'
,content: obj.message,
btn:['确定','取消'],
yes:function () {
//确定按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
},
btn2:function(){
//取消按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
},
cancel:function(){
//×按钮
self.location="{:url('index/index')}";
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
}
});
}
}
});