in reply to CGI from Java Script with return to that Java Script
I think Ajax is what you need. See here for a simple example, or CGI::Ajax for a Perl module.