Khairu Aqsara
Khairu Aqsara

Reputation: 1310

Determine execution time From beforeSend to Success in Jquery

Is possible to Determine execution time (seconds) in Jquery ajax request ? between beforeSend function to success or error function, like beforeSend -> 30 secnds ->success, may be you gusy have the answer, i tough it same like php execution time function, but i have no clue how to that, i wanna make some progress bar process but from client side not from server side after all.

Upvotes: 0

Views: 742

Answers (2)

Ben
Ben

Reputation: 515

Just use the setTimeout function in the success parameter:

beforeSend: function(){ 
       -animation (your progress bar)- 
       }
success: function(msg){
     setTimeout(function(){
               -show your success-  
           },3000);
         } 

Upvotes: 0

Yasser Shaikh
Yasser Shaikh

Reputation: 47774

You could get the time in milliseconds from the date object.

var beforeSend = new Date().getTime();

YourAjaxCallMethod();

function SuccessFunctionOfMyAjaxCall() {
    console.log(new Date().getTime() - start);
}

Borrowed from here

Upvotes: 3

Related Questions