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