in reply to Re: jQuery and Perl
in thread jQuery and Perl
There is no convenient way (that I'm aware off) to interweave Perl and Javascript to make the RPC transparent.CGI::Ajax does this, although it seems to be looked down on as somewhat inefficient because it inserts the necessary javascript to stitch the Perl and JS halves together into the <head> of each page rather than providing a cacheable .js file.
The basic technique for using CGI::Ajax is that you define sub my_ajax_function normally in Perl, then insert the javascript my_ajax_function(['input_div'], ['output_div']); into your HTML page. When the js function call executes, CGI::Ajax passes the content of input_div off via AJAX call, which CGI::Ajax intercepts and directs to the Perl sub, then the Perl sub's output is sent back in the AJAX response and inserted into output_div. You can also adjust the javascript function call to pass multiple input/output divs or to send the output into another javascript function if you don't want to just replace a div's content with it.
Very slick and easy as can be if you're willing to accept the bloat that it inserts into the page headers.
Of course, all that you said regarding making the page usable without javascript first still applies.
|
|---|