Hi,
Ajax.Updater is for updating the contents of an element with the
result of the request. I don''t know what you mean by "...return 3
or
4 values to this page" unless you mean you want to update three or
four different elements with the result of a single call.
If that''s what you want to do, you''ll want to use Ajax.Request
instead, return some structured information (perhaps JSON-formatted
data), and use the onSuccess handler to update the elements with the
structured information. For example, your call might return an object
in JSON format like this:
{
updates: {
''header'': ''<h1>This is the HTML content
for the header div</
h1>'',
''body'': ''<p>This is is the content
for the body div</p>'',
''footer'': ''This is the content for the footer
div.''
}
}
...where ''header'', ''body'', and
''footer'' are the IDs of the elements
you want to update. Your onSuccess handler would look something like
this:
function handleRequestSuccess(transport)
{
var updates;
if (transport.responseJSON && transport.responseJSON.updates)
{
updates = transport.responseJSON.updates;
for (target in updates)
{
$(target).update(updates[target]);
}
}
else
{
handleRequestFailure(transport);
}
}
FWIW.
--
T.J. Crowder
tj / crowder software / com
On Jun 5, 7:18 pm, mjhaston
<mich...-H9i9S/IRogJ7tPAFqOLdPg@public.gmane.org>
wrote:> Using a simple Prototype function that works great currently. Now I
> find I need to return 3 or 4 values to this page. These values are
> then passed when the page is submit.
>
> Any example of returning multiple values would be appreciated.
>
> <script type="text/javascript">
> function run_ajax() {
> var url = ''/fuploadp/namertv.cgi'';
> var pars =
''season=''+escape($F(''v_season''))+
''&style='' +
> escape($F(''v_style'')) + ''&special=''
+ escape($F(''v_special'')) +
> ''&color='' + escape($F(''v_color''));
> var target = ''serverfile'';
> var myAjax = new Ajax.Updater(target, url,
{method:''get'',
> parameters:pars});
> }
> </script>
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---