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

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;
HTML:
<!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.

meh.

In reply to Peculiar (but probably expected) CGI::Ajax and CGI::Application problem by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.