Show progress for ongoing download phone-gap application

Here the example for showing progress of ongoing download file.

You need below line in your .html file:

<div id="status"></div>

You need to write below code in your javascript file:

var fileTransfer = new FileTransfer();
fileTransfer.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
statusDom.innerHTML = perc + "% loaded...";
document.getElementById("ft-prog").value = perc;
} else {
if(statusDom.innerHTML == "") {
statusDom.innerHTML = "Loading";
} else {
statusDom.innerHTML += ".";
}
}
};

You may also like

Leave a Reply