在ajax成功后,确认按钮点击,关闭当前弹窗页:
//关闭当前页 var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index);
实际应用:
layui.use('form',function () { var form = layui.form; //买方退款和撤销 $("#mftkCx").click(function () { var cxmm = $("#cxmm-third").val(); $.ajax({ url: '../zjjgx/mftkCx', data: {'cxmm':cxmm}, type: 'post', dataType: 'json', success: function (obj) { if (obj.success){ //撤销和退款成功 layer.alert(obj.msg,'',function () { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index);//关闭当前页 }); }else { layer.alert(obj.msg,'',function () { location.reload(); }); } }, error: function () { layer.alert("后端请求错误,请重试",'',function () { location.reload(); }); } }); }); });