CGI-Ajax - External script

Posted on Tue Mar 13 12:26:46 2007 by nrodriguez
External script

Hello all. I'm developing an applications that uses an external perl script where is the subrutine that must be executed when the javascript event is launched. The issue is that I don't know what I'm doing wrong, but when the event run, the web page return an "internal server error".

I'm following the steps shown in the cpan documentation:

I think the error is in the first script (I resume it here):

#!/usr/bin/perl use strict; use CGI; use CGI::Ajax; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'sumar' => 'Ajax.pl'); print $pjx->build_html( $cgi, \&mostrar_formulario); sub mostrar_formulario { my $html = <<EOHTML; <HTML> <BODY> Fill in the cells with numbers and they will be added <table> <tr><td><input type="text" name="pwd" id="pwd1" onKeyUp="sumar(['pwd1', 'pwd2'], ['resultado'] );"> +</td></tr> <tr><td><input type="text" name="pwd" id="pwd2" onKeyUp="sumar(['pwd1', 'pwd2'], ['resultado'] );"> +</td></tr> <tr><td><input type="text" name="pwd" id="pwd3" onKeyUp="sumar(['pwd1', 'pwd2'], ['resultado'] );"> +</td></tr> </table> <div id="resultado"></div> </BODY> </HTML> EOHTML return $html; }

This little example works fine if all the subrutines are in the same perl script.

The script Ajax.pl exists (with execution privileges) and it has the subrutine 'sumar'. By now, it does nothing, in order to determine where is the error.

Could anyone help me? The documentation in the www shows the same examples in all sites.

Thanks.

Write a response