Look into CGI::Ajax. There are several examples in the docs.
In reply to Re: (OT) how to call cgi script from javascript? by Eliya in thread (OT) how to call cgi script from javascript? by aurora26