#!C:/xampp/perl/bin/perl.exe -w use strict; use CGI; use CGI::Ajax; use Template; # for template toolkit support use CGI::Carp qw[fatalsToBrowser]; #DEBUG ONLY my $config = { INCLUDE_PATH => '/tt', # or list ref INTERPOLATE => 1, # expand "$var" in plain text POST_CHOMP => 1, # cleanup whitespace PRE_PROCESS => 'header', # prefix each template EVAL_PERL => 1, # evaluate Perl code blocks }; my $cgi = CGI->new; my $pjx = CGI::Ajax->new( 'login' => \&do_login ); my $tt = Template->new(); print $pjx->build_html($cgi, \&main_page); sub do_login { my $input = shift; # do something with $input my $output = $input . " was the input!"; return( $output ); } sub main_page { my $template = "main.tt"; return $tt->process($template, { title =>'AJAX Login'}) or die $tt->error; }