Tell me, it’s very urgent to figure out how to fill out a form, send data to a perl-script, and then return the result to the page without reloading. While such a simple example

<html lang="en-US"> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ // по завершению загрузки страницы $('#myform').submit(function(){ $.ajax({ type: "POST", url: "1.html", success: function(data){ $(".result").html(data); } }); return false; }); }); </script> </head> <body> <form id="myform" method="get" action="1.pl"> <input type="text" name="surname" id="username"> <input id="submit_button" type="submit" value="Отправить"> </form> <div class="result"> </div> 

</ body> </ html>

And a perl handler

 #!/usr/bin/perl -w use CGI; use Fcntl; $q = CGI->new; my $f = $q->param("surname") . "Пенза!"; return $f; 

By clicking on the button, the page code is returned and another page for data entry and a button is displayed on the page.

  • one
    It feels like this code is also random ... It’s a long time to sort out all the plumes, but the first question (others will be if you demonstrate an understanding of what you write): what do you think, to what URL the form is sent when you click on "Submit"? - user6550

1 answer 1

This is how a pearl barley would look like if it reached it:

 #!/usr/bin/perl use strict; use utf8; use CGI::Carp qw/fatalsToBrowser/; my $cgi = CGI->new; my $surnanme = $cgi->param('surname').'Пенза!'; print "Content-Type: text/plain;charset=UTF-8\n\n$surname"; 

Compare and try to list your mistakes.