### in my code
my $foo = $cgi->param('foo');
# do a bunch of things with $foo,
# get data out of SQLite,
# prepare html output,
print "Content-Type: text/html\n\n", $template->output;
### in my template
####
### in my code
my $foo = $cgi->param('foo');
# figure out if XMLHttpRequest
if ($foo) {
# do a bunch of things with $foo,
# get data out of SQLite,
# prepare XMLHttpRequest output
print "Content-Type: text/html\n\n", $output;
# for all other normal cgi requests
} else {
# grab cgi params,
# do a bunch of things with them,
# get data out of SQLite,
# prepare html output,
print "Content-Type: text/html\n\n", $template->output;
}
### in my template,
# document.getElementById("output").innerHTML = output;