How can i execute PHP sleep() function as a background process with AJAX or other Javascript? Or can you tell me alternatives of this function?
答案 0 :(得分:0)
You can use the Javascript setInterval function to periodically call your random dice function every given interval (in the example below I set this to 3 seconds. This will be much more efficient than using sleep.
<script>
var myVar = setInterval(function(){ randomDice() }, 3000); // 3000 ms = 3s
function randomDice() {
//assign random number and write to some div
}
</script>