Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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 answers
Answer question

0

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!