my $cgi = CGI->new(); my $pjx = CGI::Ajax->new('js_fun'=>\&perl_fun); sub per_fun{ ... print $cgi->start_table({id=>'resulttable'}), ... } sub show_html{ //partial code print $html_fh $cgi->start_html( -title=>'Selected GEO MetaData', -style=> {-src=>[ "jquery-ui-1.8.20.custom.css", "jq_tablesorter/themes/green/style.css", "jq_ui_redmond/css/selectable.css", ] }, -script=>[ { -type => "text/javascript", -src => "$tempdir/jq/js/jquery-1.7.2.min.js" }, { -type => 'text/javascript', -src => "$tempdir/jq/jq_tablesorter/jquery.tablesorter.min.js" }, { -type => 'text/javascript', -src => "$tempdir/jq/jq_ui_redmond/js/jquery-ui-1.8.20.custom.min.js" }, q< $(document).ready(function(){ $("#metatable").tablesorter(); $("#resulttable").tablesorter(); )} .... $("#done").click(function(){ $("#metatable").slideUp(); js_fun(['val1'],['result1']); //ajax return false; }) ..... print $cgi->div({id=>'result1'}); ..... }