-2

I have a call to a page which I call as follows:-

include_once('status.controller.php');

I want to call this function every 5 seconds, so it re-runs the scripts without refreshing the whole page.

How can I do this?

I've tried:-

var interval = 4800;

setInterval(function() {
    $.get('status.controller.php', function(data) {
      //do something with the data
      alert('Load was performed.');
    });
}, interval);

but it doesn't appear to be re-running the scripts on the page as it is not updating the session variables as it should be.

nsilva
  • 5,184
  • 16
  • 66
  • 108

2 Answers2

0
        $("document").ready(function() {
          window.setInterval(function(){
          $.ajax({
            url: 'status.controller.php.php',
            success: function(data) {
            }
          });
        }, 5000);

This will work for you, just include jQuery js files, if you hadnt.

Source : What's the easiest way to call a function every 5 seconds in jQuery?

Community
  • 1
  • 1
Gaurav Gandhi
  • 3,041
  • 2
  • 27
  • 40
0
<script>
$(function(){
setInterval(function(){
    $.ajax({
        url:'status.controller.php',
        success:function(data){
            if(data == "status.controller.php"){
            }else{
                alert(data);
                location.reload();
        }
        }
    });
},4000);
});
</script>

I think this is your questions respond.

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
Eray İzgi
  • 36
  • 4