rlm@0: #!C:/strawberry/perl/bin/perl.exe rlm@0: rlm@0: use strict; rlm@0: use CGI::Ajax; rlm@0: use CGI; rlm@0: rlm@0: my $func = sub { rlm@0: my $input = shift; rlm@0: return "got input: $input " ; rlm@0: }; rlm@0: rlm@0: rlm@0: sub Show_HTML { rlm@0: my $html = < rlm@0: CGI::Ajax Example rlm@0: rlm@0: rlm@0: rlm@0:
rlm@0: Enter Something:  rlm@0:
rlm@0: Enter Something:  rlm@0:
rlm@0:
rlm@0:
rlm@0: rlm@0:
rlm@0: rlm@0: rlm@0: rlm@0: EOT rlm@0: rlm@0: } rlm@0: rlm@0: my $cgi = new CGI(); # create a new CGI object rlm@0: my $pjx = new CGI::Ajax( 'jsfunc' => $func ); rlm@0: # the default encoding for CGI::Ajax is encodeURIComponent; rlm@0: # if this causes problems, you can use escape or your own javascript rlm@0: # function; rlm@0: $pjx->js_encode_function('escape'); rlm@0: print $pjx->build_html($cgi,\&Show_HTML);