要直接请求,避免利用异步。
如下:注释掉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'
});
}
},
});*/
});
});