Xhr上传event.loaded问题

时间:2013-06-28 17:25:16

标签: javascript ajax upload

opts.xhr=function(){
    var xhr = new window.XMLHttpRequest();

    // Upload progress
    xhr.upload.onprogress = function(e) {
        if (e.lengthComputable) {
            var percentComplete = e.loaded / e.total * 100;
            console.log('Progress info:', e.loaded, e.total, Math.round(percentComplete),  Math.round(e.loaded/1024/1024), Math.round(e.total/1024/1024));
        }
    }
    return xhr;
}
return $.ajax(opts);

进展信息:53657600 2666153229 2 51 2543

进展信息:55656448 2666153229 2 53 2543

进展信息:57655296 2666153229 2 55 2543

进展信息:59850752 2666153229 2 57 2543

进度信息: 4489216 2666153229 0 4 2543

进度信息: 4800512 2666153229 0 5 2543

WTF?!

为什么它会跳回来?显示加载59850752然后加载4489216. O_o 我做错了什么?

请求网址:http://mydomain.com/admin/upload?callback=jQuery18307878572104964405_1372440424301

请求标题

Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryVHTBFWPenOcByyrT
Origin:http://mydomain.com
Referer:http://mydomain.com/admin/add
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
X-Requested-With:XMLHttpRequest

查询字符串参数

callback:jQuery18307878572104964405_1372440424301

请求有效负载

------WebKitFormBoundaryVHTBFWPenOcByyrT
Content-Disposition: form-data; name="images[]"; filename="smerch_BDRip-AVC.mkv"
Content-Type: application/octet-stream


------WebKitFormBoundaryVHTBFWPenOcByyrT--

0 个答案:

没有答案