Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

How can I selectively refresh part of a page?

by jlistf (Monk)
on Jun 20, 2000 at 22:51 UTC ( [id://19066]=perlquestion: print w/replies, xml ) Need Help??

jlistf has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

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?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How can I selectively refresh part of a page?
by Kozz (Friar) on Jun 21, 2000 at 04:00 UTC
    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.)
Re: How can I selectively refresh part of a page?
by le (Friar) on Jun 21, 2000 at 01:11 UTC
    Perl/CGI runs on the server not on the client. So you have to send the whole page, if something changes serverside. JavaScript is designed to work clientside, so the answer is: use JavaScript.
Re: How can I selectively refresh part of a page?
by audreyt (Hermit) on Jul 28, 2000 at 20:49 UTC
    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.

Re: How can I selectively refresh part of a page?
by audreyt (Hermit) on Jul 28, 2000 at 20:48 UTC
    Alternatively, use a DIV/IFRAME with its own HTML source pointed at a never-ending perl program that prints something every second. If you're sure the browser is Netscape, you could use the x-multipart-replace MIME tecnique. otherwise a javascript that re-fills the innerHTML each time is fine, too. Hope this helps.

    Originally posted as a Categorized Answer.

Re: How can I selectively refresh part of a page?
by mendeepak (Scribe) on Feb 18, 2012 at 06:33 UTC

    you can go for AJAX to do this work.

      Please provide an actual solution, not just "you can use X".

        The perl solution is that you need to:
        • use a hideously obsolete operating system - we're talking Windows 95 era here;
        • use a hideously obsolete web browser (IE 4, I think);
        • install the PerlScript plugin.
        Given that none of those is a really good idea, "use Javascript" really is a good answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://19066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-03-28 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found