Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How can I selectively refresh part of a page?

( #19066=categorized question: print w/ replies, xml ) Need Help??
Contributed by jlistf on Jun 20, 2000 at 22:51 UTC
Q&A  > CGI programming


Description:

Is there a way to change the text on a page without refreshing/reloading the whole page? I want to add a time to a page (with seconds) that constantly updates, but I'd rather not update the page every second. Is there some way to do this in perl? Would I need to use something like javascript or java?

Answer: How can I selectively refresh part of a page?
contributed by Kozz

This definitely requires some kind of complicity (activity) on the client (browser) side. For that, there's really only one viable approach: javascript. (There are other client-side scripting technologies, but javascript is preferable for a number of reasons.)

Answer: How can I selectively refresh part of a page?
contributed by audreyt

If the "part of the page" which needs to be updated can actually be a separate page embedded within the larger page, use an IFRAME. Its source (URL) can then be a server-side component producing the dynamic content, with a REFRESH set to your desired interval.

Alternatively...
There's multipart/x-mixed-replace. Here is some pretty good background and tutorial: server push with javascript Also read about COMET.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (6)
    As of 2014-11-28 07:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (193 votes), past polls