You may want to have a look at
OpenThought. It's a Perl module (and framework) that lets you do the kind of things you're wanting. I haven't used it yet, but I gave it a good look-over, and here are my notes on what it does:
OpenThought allows a web page to be incrementally updated with data
from the server. You can change fields on a form, e.g., without sending
a whole new page.
How OpenThought works:
- Instead of creating a page, you create a frameset with a parent
frame, an invisible communication frame and the content frame.
- In the content frame, you can do anything you would normally do
with a normal page. In addition, to use OpenThought, you can add
JavaScript calls for any event, e.g.
onclick="parent.CallUrl('anopenthoughturl', form_element, ...)"
The javascript function CallUrl in the parent frame serializes the
data from the call and sends an HTTP request to an OpenThought
application at the specified URL, with the communications frame given
as the target for the HTTP response.
- The OpenThought application deserializes the data into a Perl data
structure. The application can them perform any computation. It
then creates instructions to modify the content frame. OpenThought
transforms these to javascript and returns the results wrapped in
<script></script> tags.
- When the communication frame receives the complete page, it
executes the script, which constructs a javascript data structure,
then calls a function in the parent frame. This function uses the
data structure to update the document in the content frame.
It's easier to use than this might suggest.