Dear wise monks,
it appears i'm running into an error with CGI::Application and CGI::Ajax.
CGI::Ajax says that it "checks to see if a header() method is available to the CGI object, and then uses it. If method() isn't available, it creates it's own minimal header."
This is all fine and dandy, but when i run my code (shown below), it returns this error:
No head/html tags, nowhere to insert. Returning javascript anyway
HTML:package Notes; use strict; use CGI::Carp qw[fatalsToBrowser]; use CGI::Ajax; # hope it plays ok with C::A... use base 'CGI::Application'; my $pjx = CGI::Ajax->new ( 'export' => \&print_input ); sub setup { my $self = shift; $self->mode_param( "m" ); # mode param in query string $self->start_mode( "main" ); # starting run mode $self->error_mode("fatal_error"); $self->tmpl_path("tmpl/"); # other run modes $self->run_modes ( 'main' => 'main', ); } ### main page of the website ### when linking back to it, it's easiest to use ### <a href="?">home</a> sub main { my $self = shift; my $q = $self->query; # the CGI object my $tmpl = $self->load_tmpl( 'main.tmpl' ); $pjx->build_html( $q, \$tmpl->output ); } sub fatal_error { my $self = shift; my $error = $@; return $error; } ## ajax functions sub print_input { my $input = shift; return ($input . " was the inputted value"); } 1;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>AJAX Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +"> </head> <body> Enter something: <input type="text" name="val1" id="val1" onKeyUp="export( ['val1'], ['resultdiv'] );"> <br> <div id="resultdiv"></div> </body> </html>
Is CGI::Application not returning header tags that CGI::Ajax likes?
Please enlighten me.
In reply to Peculiar (but probably expected) CGI::Ajax and CGI::Application problem by stonecolddevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |