CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Perl and HTML...

 



kepler
Novice

Sep 4, 2015, 11:50 AM

Post #1 of 6 (2103 views)
Perl and HTML... Can't Post

Good afternon,

I'm trying to solve the following problem: 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


Laurent_R
Veteran / Moderator

Sep 5, 2015, 1:16 AM

Post #2 of 6 (2072 views)
Re: [kepler] Perl and HTML... [In reply to] Can't Post

Cross posted on Perl Monks, with some answers there: http://www.perlmonks.org/index.pl?node_id=1141092


FishMonger
Veteran / Moderator

Sep 5, 2015, 6:09 AM

Post #3 of 6 (2064 views)
Re: [kepler] Perl and HTML... [In reply to] Can't Post

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


kepler
Novice

Sep 5, 2015, 9:07 AM

Post #4 of 6 (2053 views)
Re: [FishMonger] Perl and HTML... [In reply to] Can't Post

Hi,

You might be right... I've found this example in Google. Will it work?


Code
    <html> 
<head>
</head>
<body>
<input type="button" value="Call Perl Script" onclick="callScript()" />
<div id="response"></div>
<!-- you should download jquery and store it in the same folder -->
<script src="jquery.js" type="text/javascript"></script>
<script>
function callScript(){
$.post("http://mysite.com/firstscript.pl", function(data){
$("#response").html("The Perl script says: " + data);
})
}
</script>
</body>
</html>


Using of course jquery-1.11.3.js?

Regards,

Kepler


FishMonger
Veteran / Moderator

Sep 5, 2015, 9:14 AM

Post #5 of 6 (2051 views)
Re: [kepler] Perl and HTML... [In reply to] Can't Post


Quote
Will it work?

You tell us. What happened when you tried it?


kepler
Novice

Sep 5, 2015, 4:44 PM

Post #6 of 6 (2028 views)
Re: [FishMonger] Perl and HTML... [In reply to] Can't Post


In Reply To
You tell us. What happened when you tried it?


Hi,

Well, for starters...a real mess. A few rules must be followed. The Perl script must have only one output (one print only) - so it seems. Otherwise the script runs forever... Another issue is that the parameters sent (like 'script.pl?arg1=3&arg2=56'...) must have a specific routine for reading - the ones well knowned for handling POST and GET queries don't work...Perl seems to not understand the nature of the request.

But, in the end, after a few adjustments in the Perl script, the method I've posted works fine :)

Regards,

Kepler

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives