0

I'm loading content from a PhP file into a div. It loads fine once, but I want it to reload every 5 seconds to show updates to the database. From looking on this site and others this should work fine, but it doesn't.

 <div id="Total">

     $(document).ready(function(){
      setTimeout(function(){
        $('#Total').load('points.php');
      },5000); });


  </div>
user2051199
  • 13
  • 1
  • 4

3 Answers3

1

You need to use setInterval() for execution. setTimeout() will only execute once. You need to also make sure your script is contained within a <script> block

<script type="text/javascript">
    $(document).ready(function(){
        setInterval(function(){
            $('#Total').load('points.php');
        },5000);
    });
</script>
Gabe
  • 49,577
  • 28
  • 142
  • 181
0

Use setInterval and put the script outside of Total

   $(document).ready(function(){
      setInterval(function(){
        $('#Total').load('points.php');
      },5000); });
Anton
  • 32,245
  • 5
  • 44
  • 54
0

setTimeout only triggers once. You should use setInterval insted.