当前位置:网站首页>JS post download file
JS post download file
2022-06-29 10:46:00 【linsa_ pursuer】
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> download </title>
<script>
var xmlhttp = getXMLHttpRequest();
var record = "747140577079087276";
var url = "http://xxx.com/controller/download?docId=" + record;
xmlhttp.open("POST", url, true);
xmlhttp.responseType = 'blob';
xmlhttp.setRequestHeader("Content-Type","application/json");
xmlhttp.setRequestHeader("Authorization","bearer 6870332e-6741-461b-840f-6e49fcce3baf");
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log('111');
saveAs(xmlhttp.response, record + ".xlsx");
}
};
function getXMLHttpRequest() {
var xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHttp");
}
return xmlhttp;
}
function saveAs(data, name) {
const blob = new Blob([data]);
const aElement = document.createElement('a');
const blobUrl = window.URL.createObjectURL(blob);
aElement.href = blobUrl;
aElement.download = name;
aElement.click();
window.URL.revokeObjectURL(blobUrl);
}
</script>
</head>
<body>
</body>
</html>
边栏推荐
猜你喜欢

基于STM32+RFID设计的宿舍检修管理系统

October 17, 2020: question brushing 1

Vmware的下载与安装(基本思路+详细过程)

Luoqingqi: has high-end household appliances become a red sea? Casati took the lead in breaking the game

Software test model (V model and W model)

BUUCTF--reverse1

解决zxing的QR码包含中文时乱码的问题

Ora-01950 does not have permission on tablespace

Voir le classement des blogs pour csdn

BUUCTF--reverse2
随机推荐
Vmware的下载与安装(基本思路+详细过程)
std::make_ shared<T>/std::make_ Unique < T> and std:: shared_ ptr<T>/std::unique_ The difference and relation between PTR < t >
1- database understanding
在实践中学习Spark计算框架(00)
Bug的描述、定级、生命周期
Call another interface button through win32API
BUUCTF--reverse2
Analysis of reentrantlock source code of AQS
Redis installation and cluster setup under Linux
有人遇到FlinkCdc同步MySQL时候出现的这个问题吗?
BUUCTF RE-easyre
【C语言进阶】字符串和内存函数(二)
Comment terminer rapidement une partition de disque
Buuctf-- connotative software
打印100~200之间的素数(C语言)
细粒度识别、分类、检索数据集整理
# 【OpenCV 例程200篇】214. 绘制椭圆的参数详解
BUUCTF--reverse1
SQL Server 数据库增删改查语句
【Rust每周一库】Tokei - 统计代码行数等信息的实用工具