Auto updating the Client page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    Auto updating the Client page

    Hi guys, I have got a question.

    I have a client page .php and a php script to server that client page.

    So can my php page in server can send the updated values for every 1 minute to client page?

    I hope you understood my question.

    Regards
    Dheeraj Joshi
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    well, I don't understand what you want to do with the php scripts, but you can use a cronjob to repeatedly execute something.

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Server does not send anything to client spontaneously. It only "serves" requests from the client.

      The client initiates all communication with a server. (Like in a restaurant: every restaurant server in the city doesn't come to your house without being asked)

      Thus, your next question would be:

      How do I make the client request every 60 seconds?

      Now that's a better question. The answer? JavaScript !!

      You can have JavaScript run something every set period of time. This could be an AJAX function or a function to reload the page (re-request the data from the server)

      Want a head start?

      Code:
      // reload the page every 60 seconds
      setTimeout(location.reload(), 60000);
      Cheers,



      Dan

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        If you're really keen on pushing data to the client from the server look up key words like: Reverse Ajax, Comet, Ajax Push, Full Duplex Ajax and Streaming Ajax. It's not an easy implementation and there are a lot of factors to consider so you may change your mind and stick with what Dlite922 recommended....

        Dlite922's solution is much much easier to understand and implement :)

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Originally posted by dlite922
          Server does not send anything to client spontaneously. It only "serves" requests from the client.

          The client initiates all communication with a server. (Like in a restaurant: every restaurant server in the city doesn't come to your house without being asked)

          Thus, your next question would be:

          How do I make the client request every 60 seconds?

          Now that's a better question. The answer? JavaScript !!

          You can have JavaScript run something every set period of time. This could be an AJAX function or a function to reload the page (re-request the data from the server)

          Want a head start?

          Code:
          // reload the page every 60 seconds
          setTimeout(location.reload(), 60000);
          Cheers,



          Dan
          A better solution would be to update only a section of the page, using your suggestion of AJAX. Otherwise, you may be wasting bandwidth.


          Big ears,
          Mark.

          Comment

          Working...