0

I wand to refresh my notification count every 10 seconds.

<span class="badge badge-danger badge-counter">
    <?php getUnreadMsgCount($uid) ?>
</span>

how to run again and again this function to get my notification count This function stored in another page

  • You cant do this with php. but you can set `setInterval` in js to request every n second. if you want to use every n minute. you can use `cronjobs`. – ttrasn Dec 25 '19 at 11:25
  • Look [here](https://stackoverflow.com/questions/17529783/how-do-you-set-interval-to-ajax-call-in-jquery). – kidA Dec 25 '19 at 11:58
  • Does this answer your question? [how do you set interval to ajax call in jquery](https://stackoverflow.com/questions/17529783/how-do-you-set-interval-to-ajax-call-in-jquery) – kidA Dec 25 '19 at 12:00

1 Answers1

0

Please try this code

<div id="sample">Testing refresh every 5 seconds</div>

 I would take a look at this below as well, although it may not be relevant in your case.

http://stackoverflow.com/questions/729921/settimeout-or-setinterval

Java Script

$(document).ready(
function() {
  setInterval(function() {
     var someval = Math.floor(Math.random() * 100);
     $('#sample').text('Test' + someval);
  }, 10000);  //Delay here = 10 seconds 
});
Full Stop
  • 904
  • 11
  • 24