#!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 }; my $cgi = CGI->new; my $pjx = CGI::Ajax->new( 'login' => \&do_login ); my $tt = Template->new($config); 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'; my $vars = { title =>'AJAX Test' }; my $output = ''; $tt->process($template, $vars, \$output) || die $tt->error(), "\n"; return $output; } #### malformed header from script. Bad header=<html><head><script type="text: ajax.cgi #### #!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; }