标签:文件 this jscript send status 方式 blob type function
//创建 XMLHttpRequest 对象
var xhr = new XMLHttpRequest();
//配置请求方式、请求地址以及是否同步
xhr.open(‘POST‘, ‘./play‘, true);
//设置请求结果类型为 blob xhr.responseType = ‘blob‘;
//请求成功回调函数
xhr.onload = function(e) {
if (this.status == 200) {
//请求成功
//获取 blob 对象
var blob = this.response;
//获取 blob 对象地址,并把值赋给容器
$("#sound").attr("src", URL.createObjectURL(blob));}};
xhr.send();标签:文件 this jscript send status 方式 blob type function
原文地址:https://www.cnblogs.com/yishenweilv/p/11906391.html