views:

22

answers:

1

Whenver Ajax requests new data from the server this can sometimes take a a second or two. Now I want to know, how can I get this time between the ajax request and the response it gets from the server?

I need this because an ajax timer I'm running ain't perfectly doing his stuff. It got some delay whenever it needs to reset to it's original time.

Thanks in Advance.

Edit: Help needed fast please, just try.

A: 

Such as getting the current time when making the request, doing the same when getting a response and getting the difference to know the elapsed time?

What specifically is your problem? You don't know the javascript for this? If you're in that much of a hurry im guessing google would be faster than SO.

Edit

var date1 = new Date();
setTimeout("getElapsed()",1000);

function getElapsed()
{
var date2 = new Date();
alert(date2.getTime()-date1.getTime());
}

This throws an alert with "1008" on my machine - this equates to milliseconds.

Jamiec
Indeed I can't really find the script that gets this elapsed time. And the same goes for the search time I got, I've got a few other things to do at same time.
Julian
Example js added to answer
Jamiec