function exportData(){
$(".bj_black").show()
$("#loding").show()
const url = "/physicalDetect/export?classId=" + $('#classId').val() +"&lessonId=" + $('#lessonId').val(); //记得拼接参数
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true); // 也可以使用POST方式,根据接口
//xhr.setRequestHeader('token', sessionStorage.getItem('token')); // 设置token
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.responseType = 'blob'; // 返回类型blob
xhr.onload = function(e) {
if (this.status === 200) {
//理论上要用文档流来下载 但是IOS会GG
/* const blob = this.response;
const reader = new FileReader();
reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
reader.onload = function(e) {
const a = document.createElement('a');
a.download = $("#coursePacketName").html() + '.doc';
a.href = e.target.result;
document.documentElement.appendChild(a);
a.click();
a.remove(); // 等价于document.documentElement.removeChild(a);
$(".bj_black").hide()
$("#loding").hide()
}; */
//用最原始的方法来做 反正到了这里已经触发了跳转 弹窗确实可以关闭了
window.location.href = url
$(".bj_black").hide()
$("#loding").hide()
}
};
xhr.send(); // 发送ajax请求
}