In JavaScript, a block of code can be executed in specified time intervals. These time intervals are called timing events. There are two methods for executing code at specific intervals. They are:
- setInterval()
- setTimeout()
In this tutorial, you will learn about the setInterval()
method.
<script> let userID = '<?php echo $user_id; ?>'; $(document).ready(function(){ function getStatus(){ $.ajax({ url:'https://forlancer.in/php/app/fetch_project_status.php', method:'POST', data:{userid: userID}, success:function(data){ if(data != 404){ $('#notification_modelpk').trigger('click'); } else{ } } }); } getStatus(); setInterval(getStatus, 10000); }); </script>