要直接請求,避免利用異步。
如下:註釋掉ajax異步請求,換做直接請求後臺,問題解決!
// 批量導出
$('#batchExport').on('click', function(){
layer.confirm('確認導出表中的主機嗎?', {icon: 3, title:'系統提示'}, function(index){
layer.close(index);
window.location.href = base_url + '/resmanage/exportHostExcel';
/*$.ajax({
type : 'GET',
url : base_url + '/resmanage/exportHostExcel',
data : {},
//dataType : "json",
//contentType:"application/x-www-form-urlencoded",//(可以)
success : function(data){
alert(data);
if(data == "success"){
layer.open({
title: '系統提示',
content: '導出成功!',
icon: '1',
end: function(layero, index){
//window.location.reload();
}
});
}else {
layer.open({
title: '系統提示',
content: (data.msg || "導出失敗!"),
icon: '2'
});
}
if (data.code == 200) {
layer.open({
title: '系統提示',
content: '導出成功!',
icon: '1',
end: function(layero, index){
window.location.reload();
}
});
} else {
layer.open({
title: '系統提示',
content: (data.msg || "導出失敗!"),
icon: '2'
});
}
},
});*/
});
});