I just want to show the amount of data fetched from Api.
output should be like 10% fetched 90 % remaining like that.
I'm searching how should I calculate the amount the amount retreived and remaning data left to be fetched.
I have googled and found a link: Monitoring_progress but if any body could suggest to me where to start I would much appreciate.
As far as I know there is no way to get the exact time, but you can get an approximation.
Most of the time is spent in the basecamp
servers, not in the request. The link you posted offers a way for basecamp
to push progress messages. If they don't do so, you will get nothing.
You can imagine the basecamp
servers as a wall. Behind the wall is the progress, but you can't see behind a wall and you are not allowed by basecamp
to climb it.
You can approximate this time. With a method similar to what is posted here:
var ajaxTime= new Date().getTime();
$.ajax({
type: "POST",
url: "some.php",
}).done(function () {
var totalTime = new Date().getTime()-ajaxTime;
});
you can measure how long it will take to complete a request.
Than you calculate the mean time
of all requests made to an url
. That time will be good enough.
I recommend something like this:
To display a fix amount of time as a percent you can do like this:
secondsPerPercent = timeInSeconds / 100
<-- this is how many seconds need to pass for a percent to be filled. secondsPerPercent
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.