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

Perl and html

by kepler (Scribe)
on Sep 05, 2015 at 00:45 UTC ( #1141092=perlquestion: print w/replies, xml ) Need Help??
kepler has asked for the wisdom of the Perl Monks concerning the following question:

Good evening,

I'm trying to solve the following problem (also posted in code guru, but no answer...): I have a normal html page with a form that submits to a perl script. This last one gives an output (text or html).

I want to reload the exact same first html page with the results of the script in a span, ul, or whatever...

Any ideas?...

Regards,

Kepler

Replies are listed 'Best First'.
Re: Perl and html
by wjw (Priest) on Sep 05, 2015 at 00:57 UTC

    Have the script deliver the original html page, then return both the original page and the results back to the client using whatever formatting you want. You can tell whether it is an initial load or a form submit when your script receives the request...

    ...one of many ways.. Hope that is helpful.

    ...the majority is always wrong, and always the last to know about it...

    A solution is nothing more than a clearly stated problem...

      Hi,

      That was my original idea. But the problem is the page html menu links. The html page and the script are in diferent locations...which is a mess...How c

      an I give back the html page in the right place?...

        Hi, That was my original idea. But the problem is the page html menu links. The html page and the script are in diferent locations...which is a mess...How can I give back the html page in the right place?...

        :) So now you know what you have to fix, fix the links

        Several approaches, mostly, have the original page simply call / redirect / link to the "program", and have the program present all the html with all the links fixed

Re: Perl and html
by Anonymous Monk on Sep 05, 2015 at 13:13 UTC

    The OP's question is cross posted on perlguru. http://perlguru.com/gforum.cgi?post=82016;#82016
    Where I gave this answer.

    Sounds like your form should be executing the perl script via an AJAX call which then updates the page.

Re: Perl and html
by sundialsvc4 (Abbot) on Sep 05, 2015 at 15:54 UTC

    Based only on the response given just-above ... if the HTML page uses a <form action= ...> tag, to actually submit POST data and get a complete HTML page in return, then you could replicate that easily with something like LWP::UserAgent.   But if the form actually does what is more common these days, and gathers the data in order to do an AJAX call for which the Perl script will simply return (say ...) JSON, you have a much different problem.   The interaction (including the subsequent updates to the form’s DOM content) is happening programmatically, when the web-page is in service.   Obviously, you would prefer not to programmatically replicate in Perl what it is now doing.

    One possible strategy would be to use Selenium, which is a testing framework that engages the services of actual web browser processes.   (A search of http://search.cpan.org reveals about 85 Selenium-aware CPAN modules.)   This would allow you to engage an actual web browser, then examine its screen after the JSON exchange has been completed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1141092]
Approved by 1nickt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-12-13 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (62 votes). Check out past polls.

    Notices?