I just found this feature in wordpress 2.0 under cerntain themes (say, k2). When a user submits his comment, the whole page is not reloaded while the new comment is added. I don't know any pragmatic utility of such a feature. But superficially, it's really amazing :-)

Comments

Zen’s picture

This can be done for everything really (alá gmail)..

But everything becomes twice the effort (in Drupal) - you have to design the AJAX version and the non-JS version to cater to users without javascript..

-K

Thox’s picture

I'm 10% sure we already support commenting without JS ;o)

This kind of feature would be (I think) the first time we'd be using AJAX to submit a form. It's probably worthwhile at that stage to use a bigger AJAX library, although not even prototype.js handles submitting forms with AJAX simply.

CnnmnSchnpps’s picture

I have recently started to play with xajax, and I love it. After the initial setup, most AXAJ functionality takes only a few lines to implement. Some of the niftier things it provides:

- autogeneration of necessary javacsript (since learning PHP is hard enough)
- passing complex data structures between server and client
- passing extra JS code to the client asynchronously

The latest version of it is "0.2 stable". I like stable. It makes me feel really safe.

jjeff’s picture

I'm in the process of writing a module to bring Prototype/Scriptaculous to Drupal. The functionality that you're talking about sounds very cool. I don't know if there's a way to do this without modifying the theme, but I will experiment with some code in this direction.

I haven't gotten as far as full form submissions using Prototype, so Thox may be right about this being tricky. But maybe there's a way we can wrap the code so that we can abstract it away with a function like prototype_ajax_submit_form($form_id, $callback_path, $return_div_id); that would insert some JS into the page that would reroute the form with the id $form_id to the $callback_path and insert the results into the div with $return_div_id... or something like that...

--= Jeff Robbins | www.lullabot.com =--

CnnmnSchnpps’s picture

Again, xajax already provides this functionality for you.. It allows you to pass complex data structures (including forms) between PHP on the server and JS on the client (and vice versa), while doing all the "dirty" work.