如何计算winxhr的进度 [英] How to calculate progress winxhr
问题描述
大家好
我使用以下代码下载视频我成功获得blob数据但我无法计算进度百分比。请帮助我。
WinJS.xhr({url:vurl,responseType:" blob"})
.done(功能完成) (结果){
//用blob做一些事情
},
函数错误(错误){
//日志错误
},
函数进度(结果){
if(result.readyState> ; 2){
// var totalBytes = result.getResponseHeader('Content-length');
// var dlBytes = result.responseText.length;
// var per =(totalBytes> 0)?(Math.round ((dlBytes / totalBytes)* 100)+%):( Math.round(dlBytes / 1024)+K);
// $(&#; #vmDownloadHeading" ).html(" Downloading Media" +每个);
}
});
如果我使用响应类型作为文本我可以计算通过上面的代码进展,对于其他响应,它将是未定义的,所以如何计算进度?
问候
vinay
hi all
I am using following code to download video i am getting blob data successfully but i am not able to calculate progress percentage. please assist me.
WinJS.xhr({ url: vurl, responseType: "blob" })
.done(function complete(result) {
//do something with blob
},
function error(error) {
//log error
},
function progress(result) {
if (result.readyState > 2) {
//var totalBytes = result.getResponseHeader('Content-length');
//var dlBytes = result.responseText.length;
//var per = (totalBytes > 0) ? (Math.round((dlBytes / totalBytes) * 100) + "%") : (Math.round(dlBytes / 1024) + "K");
//$("#vmDownloadHeading").html("Downloading Media " + per);
}
});
if i use response type as text i can calculate progress by above code, for other response it will be undefined so how to calculate the progress?
regards
vinay
推荐答案
(&#vmDownloadHeading")。html(" Downloading Media" + per);
}
});
如果我使用响应类型作为文本我可以通过上面的代码计算进度,对于其他响应它将是未定义的,所以如何计算进度?
问候
vinay
("#vmDownloadHeading").html("Downloading Media " + per);
}
});
if i use response type as text i can calculate progress by above code, for other response it will be undefined so how to calculate the progress?
regards
vinay
这篇关于如何计算winxhr的进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!