Xhr uploading event.loaded issue

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

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); 

Progress info: 53657600 2666153229 2 51 2543

Progress info: 55656448 2666153229 2 53 2543

Progress info: 57655296 2666153229 2 55 2543

Progress info: 59850752 2666153229 2 57 2543

Progress info: 4489216 2666153229 0 4 2543

Progress info: 4800512 2666153229 0 5 2543

WTF?!

Why it's jumping back? Shows 59850752 is loaded and then 4489216. O_o What i'm doing wrong?

Request URL:http://mydomain.com/admin/upload?callback=jQuery18307878572104964405_1372440424301

Request Headers

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 

Query String Parameters

callback:jQuery18307878572104964405_1372440424301 

Request Payload

------WebKitFormBoundaryVHTBFWPenOcByyrT Content-Disposition: form-data; name="images[]"; filename="smerch_BDRip-AVC.mkv" Content-Type: application/octet-stream   ------WebKitFormBoundaryVHTBFWPenOcByyrT-- 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!