in reply to jQuery and Perl

My approach is to first build a static site that works without Javascript. After I've hammered out the functionality with HTML+Perl, I then use jQuery to add more interactivity. Usually this means using the jQuery $.ajax() function to request a page from the server and to rip out specific parts of the HTML and to insert that part into the current page. If you want to dynamically update a data display, you will likely need to supply that data (preferrably in JSON format) to jQuery.

You need to realize that to have a HTML/Javascript button execute some Perl code, you will need to make a request from the browser to your server. There is no convenient way (that I'm aware off) to interweave Perl and Javascript to make the RPC transparent. But I think you can get by without that transparency quite well if you use the approach of first creating a functional, non-JS version and then add the "no page reload" functionality on the client side.

Replies are listed 'Best First'.
Re^2: jQuery and Perl
by wazoox (Prior) on May 27, 2010 at 15:53 UTC
    This has another huge added benefit : your site works even without javascript (noscript extension, security settings, disabilities, etc).
Re^2: jQuery and Perl
by dsheroh (Monsignor) on May 28, 2010 at 10:23 UTC
    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.