Automatic refresh a section after few seconds using jQuery
×


Automatic refresh a section after few seconds using jQuery

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>



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments