Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Is it wrong to periodically refresh a div in html?

I own a small messaging platform and I'm trying to make it live, so everything needs to work without any refresh. Messages are sent with Ajax and the procedure is refresh-free. I'm also trying to make sure that when Alice sends a message to Bob, Bob receives it (almost) immediately. For this reason, I'm refreshing the div containing all of the messages every second with this script:

      <script>
         $(document).ready(function() {
         var pageRefresh = 1000;
             setInterval(function() {
                 refresh();
             }, pageRefresh);
         });
         
         function refresh() {
             $("#messagesframe").load(" #messagesframe > *");
         }
      </script>

      <div id="messagesframe">
      <!-- messages displayed here! -->
      </div>

This makes sure that every second the new messages are shown. I have a doubt, however, that this may slow down the application. I am asking you, thus, whether this doubt is well-founded or if this procedure is harmless. Any help is appreciated.

Note: I'm using PHP.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

this kind of code is not Optimal, best way for real time applications is using socket technology

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda