Javascript 尝试下载blob时,XMLHttpRequest出现错误-Firefox中的状态为206(在Chrome中工作)
当我尝试在Firefox中下载mp4文件(仅300K)时,它会给出Javascript 尝试下载blob时,XMLHttpRequest出现错误-Firefox中的状态为206(在Chrome中工作),javascript,ajax,html,firefox,xmlhttprequest,Javascript,Ajax,Html,Firefox,Xmlhttprequest,当我尝试在Firefox中下载mp4文件(仅300K)时,它会给出206状态,从不200,也从不下载完整视频。它在Chrome中正常工作 var blob; //Start the request var videoRequest = new XMLHttpRequest(); //Get the Video file from the server. videoRequest.open( "GET", "/videos/test.mp4", true
206
状态,从不200
,也从不下载完整视频。它在Chrome中正常工作
var blob;
//Start the request
var videoRequest = new XMLHttpRequest();
//Get the Video file from the server.
videoRequest.open( "GET", "/videos/test.mp4", true );
//It's a blob (for storing in database)
videoRequest.responseType = "blob";
//Listen for when it's done downloading the video data
videoRequest.addEventListener(
"load",
function ()
{
//This is never reached!
if ( videoRequest.status === 200 )
{
//Get the data
blob = videoRequest.response;
//Store in our database
...
}
//This is always 206!!
console.log( videoRequest.status );
},
false
);
//Start the request
videoRequest.send();
在Chrome中,它只下载完整的视频,返回200
(从不206
)
是什么导致了这种情况?你明白206是什么吗?@JaromandaX是的,但我从未设置过范围标题,所以我不应该得到它。为什么要发送?我该如何处理?你能证实它是被发送的吗?@JaromandaX你是什么意思?当我在chrome中运行它时,它会发送它并给出200状态。在Firefox中,它发送206,响应头表示它只发送最后一个字节!(它说类似字节:0-36546754/36546755)字节0-1/2表示字节0和2中的1。。。这有用吗?要检查标题,在firefox中,打开开发者工具网络选项卡(ctrl+shift+Q是快捷键)-当您看到mp4的请求时,单击它,在右侧您将看到标题选项卡等,您应该能够在其中看到请求/响应标题