robert@0: #!C:/strawberry/perl/bin/perl.exe robert@0: robert@0: # this is an example script of how you would use coderefs to define robert@0: # your CGI::Ajax functions. robert@0: # robert@0: # NB The CGI::Ajax object must come AFTER the coderefs are declared. robert@0: robert@0: use strict; robert@0: use CGI::Ajax; robert@0: use CGI; robert@0: robert@0: my $q = new CGI; robert@0: robert@0: my $exported_fx = sub { robert@0: my $value_a = shift; robert@0: my $iq = new CGI; robert@0: my $a = $q->param('a'); robert@0: my $b = $q->param('b'); robert@0: my $test = $q->param('test'); robert@0: return( robert@0: 'entered value was: ' . $value_a . robert@0: '
a was: ' . $a . "..." . robert@0: '
b was: ' . $b . "..." . robert@0: '
test was: ' . $test . "..." robert@0: ); robert@0: }; robert@0: robert@0: robert@0: my $Show_Form = sub { robert@0: my $html = ""; robert@0: $html .= < robert@0: CGI::Ajax Example robert@0: robert@0: robert@0:
robert@0: this javascript object is sent in as an argument: robert@0: {'a':123,'b':345,'test':'123 Evergreen Terrace'} robert@0:

robert@0: Enter something else:  robert@0:
robert@0: robert@0:
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: my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx); robert@0: $pjx->JSDEBUG(2); robert@0: $pjx->DEBUG(2); robert@0: print $pjx->build_html($q,$Show_Form); # this outputs the html for the page robert@0: