Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试下载blob时,XMLHttpRequest出现错误-Firefox中的状态为206(在Chrome中工作)_Javascript_Ajax_Html_Firefox_Xmlhttprequest - Fatal编程技术网

Javascript 尝试下载blob时,XMLHttpRequest出现错误-Firefox中的状态为206(在Chrome中工作)

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

当我尝试在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 );

    //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的请求时,单击它,在右侧您将看到标题选项卡等,您应该能够在其中看到请求/响应标题