me_gazza has asked for the wisdom of the Perl Monks concerning the following question:
our %myhash; my $cgi = CGI->new(); my %funchash = ( 'SUBA' => \&suba, 'SUBB' => \&subb ); my $pjx = CGI::Ajax->new( %funchash ); my $var1="aaa"; $myhash{typea}=$var1; my $template="html/mypage.html"; my $tmpl= HTML::Template::Pro->new(filename => $template,loop_context_ +vars=>1,debug=>1,global_vars=>1); print $pjx->build_html( $cgi, $tmpl->output) sub suba { # this is invoked by user clicking on dropdown box A $myhash{typeb}="bbbb"; print "$myhash{typea}"; <- this is shown correctly print "$myhash{typeb}"; <- this is shown correctly } sub subb { # this is invoked after user clicked dropdown box B after A $myhash{typec}="cccc"; print "$myhash{typea}"; <- this is shown correctly print "$myhash{typeb}"; <- this is _NOT_ shown print "$myhash{typec}"; <- this is shown correctly }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Global variables with CGI:Ajax
by Anonymous Monk on May 28, 2012 at 21:24 UTC | |
by me_gazza (Initiate) on May 29, 2012 at 08:23 UTC | |
by Anonymous Monk on May 29, 2012 at 09:42 UTC |