Perfect Mike, thank you very much.

-- Josh

----- Original Message ----- From: "Michael Geary" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Friday, September 21, 2007 10:09 AM
Subject: [jQuery] Re: Get time of ajax post?



  function now() { return (new Date).getTime(); }

  // before the ajax call
  var before = now();

     // and in your ajax success callback:
     var elapsed = now() - before;

Time is in milliseconds, but actual resolution is usually less, e.g. 15 millisecond resolution on a typical PC.

-Mike

From: Josh Nathanson

This is more of a JS queston in general than a jQuery
question: how do I get the time it took for an ajax post to complete?

I am trying to show a progress bar for an ajax post which may
take anywhere from 1 to 20 seconds.  It's a multi-row
database table update.  To do this I'm using the
"guesstimate" pattern described here:
http://ajaxpatterns.org/Progress_Indicator

To improve the accuracy, I'd like to do a "dummy" ajax post
to the server, get the amount of time it took, and use that
to calculate the total estimated time for the database
update, then do the actual multi-row update while the
progress bar is running.

I've seen timers for events in JS, such as the speed test
demos, but I can't figure out how to retrieve that
information from a completed ajax request.
Is what I'm trying to do possible?


Reply via email to