have to request only when there is a change in the database? instead of checking every second

Asked

Viewed 86 times

1

<script type="text/javascript">

  function atualizarTarefas() {


    $("#header").load("<?=site_url('home/notificar/')?>");
   }
    setInterval("atualizarTarefas()", 1000);

</script>

  • Has, the best way is using Websockets, however can also use long-Polling, so it remains with an active connection and only ends when there is update, then creates a new. See http://answall.com/questions/9475/notifies%C3%A7%C3%B5es-in-real-time-similar-to-stack-overflow/10109. PHP by default provides support for Websockets, but is not such a simple task, although there are some libraries, you can use websockets using Pubnub, Pusher, Ably.io, Scaledrone, Hydna which will be much easier.

  • okay I’ll try to understand more of the subject, Websockets thanks for the tip!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.