You're right, that's not the exact code. I'm using CGI:Ajax in addition to HTML::Template. At first, I was using strictly CGI:Ajax and doing a $template->output; directly at the end of each sub. But, I wanted to be able to work with users that don't have JavaScript enabled or portable devices that don't support JS. Now, I return the $template->output and either print it (for AJAX) or assign it to a tmpl_var in the whole page template. Putting it into the page template as a TMPL_VAR doesn't show the 1. Only printing it after an AJAX call.
It does happen with this code (stripped down version of my full script to save bandwidth): #!/usr/bin/perl -w use strict; use CGI; use CGI::Ajax; use HTML::Template; my $cgi = new CGI(); my $pjx = new CGI::Ajax('change_page' => \&change_page); print $pjx->build_html($cgi,\&Show_HTML); sub change_page { my $pg = $cgi->param('page'); print Show_Content($pg) if(defined $pg); } sub Show_HTML { my $template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/index.tmpl"); my $content = ''; my $content_template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/content/index.html"); $content = $content_template->output; $template->param(content => $content); return $template->output; } sub Show_Content { my $pg = shift; my $template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/content/$pg.html") return $template->output; } ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users