Automatic refresh a section after few seconds using jQuery
0 4263
If you want to get the latest record in the particular section without loading the page, then that means you wanna refresh that section after few seconds and this can be done by using jQuery.
Just you need jQuery to refresh the section by using a function and an Ajax file.
index.php
<!--- Start Section ---->
<span id="OrderCountActive">
<table class="table">
<tbody>
<tr>
<th scope="row"><span> Active Orders: </span></th>
<td scope="row">8</td>
</tr>
</tbody>
</table>
</span>
<!-- End Section -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!---Start Script---->
<script type="text/javascript">
setInterval(function(){ //the function to set the interval of time
$('#OrderCountActive').load('ajax_refreshsection.php');
},2000);
</script>
<!-- End Script -->
Now here is your 'ajax_refreshsection.php':
<table class="table">
<tbody>
<tr>
<th scope="row"><span> Active Orders: </span></th>
<td scope="row"> 12 </td>
</tr>
</tbody>
</table>
Share:
Comments
Waiting for your comments