rlm@0: #!C:/strawberry/perl/bin/perl.exe rlm@0: rlm@0: # this is an example script of how you would use coderefs to define rlm@0: # your CGI::Ajax functions, and the methods return multiple results to rlm@0: # the page rlm@0: # rlm@0: # NB The CGI::Ajax object must come AFTER the coderefs are declared. rlm@0: rlm@0: use strict; rlm@0: use CGI::Ajax; rlm@0: use CGI; rlm@0: rlm@0: my $q = new CGI; rlm@0: rlm@0: my $multiply = sub { rlm@0: my $a = shift; rlm@0: my $b = shift; rlm@0: return $a * $b; rlm@0: }; rlm@0: rlm@0: my $divide = sub { rlm@0: my $a = shift; rlm@0: my $b = shift; rlm@0: return $a / $b; rlm@0: }; rlm@0: my $G = 'asdf'; rlm@0: my $Show_Form = sub { rlm@0: my $html = ""; rlm@0: $html .= qq! rlm@0: rlm@0: CGI::Ajax Multiple Return Value Example rlm@0: rlm@0: rlm@0: rlm@0:
rlm@0: Enter Number: rlm@0: rlm@0: rlm@0: rlm@0: rlm@0:
rlm@0: URL FROM "this" in callback:
rlm@0: rlm@0: rlm@0:
rlm@0: rlm@0: rlm@0: !; rlm@0: rlm@0: return $html; rlm@0: }; rlm@0: rlm@0: rlm@0: my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide); rlm@0: $pjx->JSDEBUG(1); rlm@0: $pjx->DEBUG(1); rlm@0: print $pjx->build_html($q,$Show_Form); # this outputs the html for the page