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