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 }