rlm@0: #!C:/strawberry/perl/bin/perl.exe rlm@0: use strict; rlm@0: use CGI::Ajax 0.57; rlm@0: use CGI; rlm@0: rlm@0: my $q = new CGI; # need a new CGI object rlm@0: rlm@0: # compose our list of functions to export to js rlm@0: my %hash = ( 'myFunc' => \&perl_func,); rlm@0: rlm@0: my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object rlm@0: rlm@0: $pjx->DEBUG(1); # turn on debugging rlm@0: $pjx->JSDEBUG(1); # turn on javascript debugging, which will place a rlm@0: # new div element at the bottom of our page showing rlm@0: # the asynchrously requested URL rlm@0: rlm@0: print $pjx->build_html( $q, \&Show_HTML ); # this builds our html rlm@0: # page, inserting js rlm@0: rlm@0: # This subroutine is responsible for outputting the HTML of the web rlm@0: # page. rlm@0: sub Show_HTML { rlm@0: my $html = < rlm@0: Radio Example rlm@0: rlm@0: rlm@0:
rlm@0:
rlm@0: red rlm@0: blue rlm@0: yellow rlm@0: green rlm@0:
rlm@0:
rlm@0:
rlm@0: rlm@0: rlm@0: EOT rlm@0: rlm@0: return($html); rlm@0: } rlm@0: rlm@0: # this is the exported function rlm@0: sub perl_func { rlm@0: $a = shift; rlm@0: return $a . " was selected"; rlm@0: }