Hey guys am trying to get an expected download time with an ajax script..It just works fine ..I get the expected time in the format hh:mm:ss
.But the clock isnt moving The code i have tried
function get_filesize(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("HEAD", url, true);
xhr.onreadystatechange = function() {
if (this.readyState == this.DONE) {
callback(parseInt(xhr.getResponseHeader(
"Content-Length")));
}
};
xhr.send();
}
get_filesize(
"http://upload.wikimedia.org/wikipedia/commons/9/96/Google_web_search.png",
function(size) {
var estimatedtime = (new Date().getTime()) / size;
var time = new Date(estimatedtime);
var c = setTimeout(function() {
time.getHours() + ":" + time.getMinutes() + ":" +
time.getSeconds()
}, 500);
console.log(c);
});
When i try this code i get an output like 1
.
What i need as my output
Suppose the output i got is 00:57:12
i need to decrement the time as a timer like 00:57:11
ans so on.
I havnt no idea on how to try this ..i have tried setTimeout
But it didnt helped me.
Any help would be greatly appreciated..Thanx