|There's more than one way to do things|
As for your HTML page, if it's separate from your CGI, you can just put everything printed out by subroutine "print_html() into the html page, except for the "Content-type: text/html" (which will be printed for you automatically by the server, since it's in HTML.
You would then change $url in the function ajax_text(), in this line:
to be whatever the name of your actual CGI/Perl script was instead.
However, please note that you will still need the headers printed from your server-side Perl/CGI script; eg.:
If you forget that, you'll get something like this error (from my /var/log/httpd/error_log file):
Does that help you get further?
In reply to Re^3: Post from jQuery to Perl - can't access parameters