I want to show the time of process of my php code using jQuery
My php code example :
<?php
//some queries to database
?>
Here's my jQuery:
$.ajax({
type: "POST",
url: "action.php",
data: {
action: "simpanFitur", fitur: $('#feature :selected').val()
},
success: function(){
var stop = new Date().getTime()-start;
alert("Tersimpan.\n Lama proses : " + stop);
},
error: function(cek){
alert("Error");
}
});
The alert show this :
Can somebody help me how to make it more readable ? Because I dont know what value that showed on my alert. Thank you.
I've modified my ajax request to be like this :
$.ajax({
type: "POST",
url: "action.php",
data: {
action: "simpanFitur", fitur: $('#feature :selected').val()
},
success: function(time){
alert("Tersimpan.\nLama proses : " + time);
},
error: function(){
alert("Error");
}
});
But the alert didn't show the time
value.
Did I do something wrong ? Please tell me.
This is the latest alert :
How to make it more simple ?
You could always return in the action.php
response a key called time
containing the total time the request took, then you can handle this in your success section and display as you wish.
You could generate the value of time
with:
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.