$("#speedDiv").show(); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true);//get请求,请求地址,是否异步 // xhr.setRequestHeader("Content-Type", "text/plain"); xhr.responseType = "blob"; // 返回类型blob xhr.addEventListener("progress", download_progress_handler, false); xhr.onload = function () {// 请求完成处理函数 if (this.status === 200) { var blob = this.response;// 获取返回值 var a = document.createElement('a'); a.download = fileNmae + '.' + type; a.href=window.URL.createObjectURL(blob); a.click(); } }; // 发送ajax请求 xhr.send();
xhr下载MP4
最新推荐文章于 2024-03-14 14:58:14 发布