my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func); print $pjx->build_html($cgi, \&Show_Html); sub perl_func { # ajax function } sub Show_Html { # html generating code # first check session info print $session->header(); # generate html print $cgi->start_html(); # remaining html code print $cgi->end_html(); } #### sub Show_HTML { my $html = < # html generating code EOT return $html; } #### # html generated by Show_Html # and again html generated by cgi::ajax