javascript - How to calculate Fetching Time while fetching data from any Api in Ajax -


  1. i want show amount of data fetched api.

  2. output should 10% fetched 90 % remaining that.

  3. i'm searching how should calculate amount amount retreived , remaning data left fetched.

  4. i have been working on basecamp api waste lots of time fetch tasks , activities etc. want want show time left while fetching in ajax .

i have googled , found link: monitoring_progress if body suggest me start appreciate.

as far know there no way exact time, can approximation.

why can't have exact time ?

most of time spent in basecamp servers, not in request. link posted offers way basecamp push progress messages. if don't so, nothing.

you can imagine basecamp servers wall. behind wall progress, can't see behind wall , not allowed basecamp climb it.

?

you can approximate time. method similar 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 take complete request.

than calculate mean time of requests made url. time enough.

i recommend this:

  • measure times every request, 10 times.
  • calculate mean of times ( sum them , divide 10 (the number of requests))
  • save result , send when initiate application , store in browser.
  • when user makes request, precalculated time , display timer.

update

to display fix amount of time percent can this:

  • secondsperpercent = timeinseconds / 100 <-- how many seconds need pass percent filled.
  • make javascript timer (code can found on google) updates percent every secondsperpercent.

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -