Menu Search Me

Using JQuery AJAX to Post to Server Every 5 Seconds

To accomplish this, in addition to using the JQuery AJAX function $post(), you will need the JavaScript function setInterval (example and explaination refer to http://www.w3schools.com/jsref/met_win_setinterval.asp).

Below is an example:

<script>
   $(document).ready(function() {
      setInterval(function() {
         jQuery.ajax({
            url: "<path to your_action>",
            type: "GET",
            dataType: "script"
         });
      }, 5000); // In every 5 seconds
   });
</script>