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