Hey Mike,
So you've got data in a variable named, say, script.
OK. To send this to the server, you need to use an Ajax.Request to the
server (this has to be the same server, and the same port, that you got
your current web page from, btw). You'll need to bind the onComplete
(or onSuccess, depending on how picky you want to be) callback to a
method of yours, in order to lookup the returned text.
If I got you correctly, you're not interested in evaluating the updated
script, but in putting it back into its original place (form or field or
whatever). So here's an example:
# HTML
<form id="scripty" action="/your/updater/action">
<p><textarea id="script" name="script">some script</textarea></p>
<p><input type="submit" value="Send it!"/></p>
</form>
#JS
function bindFormToAJAX() {
Event.observe('scripty', 'submit', function(e) {
Event.stop(e);
$('scripty').request({
onComplete: function(transport) {
$('script').value = transport.responseText;
}
});
});
}
Event.observe(window, 'load', bindFormToAJAX);
The 'request' method added to <form>s by Prototype basically uses the
form's fields, method (defaults to 'post') and action to setup the AJAX
call. We just provide AJAX options, which here include our 'onComplete'
callback, to put the updated script back in the <textarea> once we get
the whole response.
For more details on Ajax tools, just look at the docs (including JS
auto-eval, for instance):
http://prototypejs.org/api/ajax
'HTH
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---