-1

Please, I want to use stopwatch to get the seconds from the time of sending of request through ajax and success function.

1 Answers1

0

You can do it like this:

var start_time = new Date();
$.ajax({
  // Other params
  success: function () {
    var end_time = new Date();
    alert("Time taken: " seconds(end_time) - seconds(start_time));
  }
});
function seconds(date_obj) {
  return date_obj.getTime();
}

Please figure out seconds() yourself.

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252