Possible Duplicate:
How to get progress from XMLHttpRequest
totalI am trying to download a 1 mb file with xmlhttprequest and check the download time for bandwidth measurement. However following codes give me just response time from server. It doesn't wait until all file loaded.
var start = new Date().getTime();
(function rec() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', "https://www.example.com/test/dummyFile1024kb", true);   
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
xmlHttp.onreadystatechange = function () {
     if (xmlHttp.readyState == 4) {
         var total=(new Date() - start)            
         alert(total)    
        };
       xmlHttp.send(null);
    })();
What should I do in order to download all file? Any other suggestions are welcome.
 
     
    