//創建 XMLHttpRequest 對象 var xhr = new XMLHttpRequest(); //配置請求方式、請求地址以及是否同步 xhr.open('GET', './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();