nano,
This is just one way. Use the XMLHTTP object and write the return to
the arrCustomers variable.
Scott.
nano . wrote:> I have some javascript,
>
> <script>
> var arrCustomers;
>
> function setCustomers(arr)
> {
> arrCustomers= arr;
> // arrCustomers holds now array of customers
> }
> </script>
>
>
> ... and Rails controller,
>
> class CustomersController < ApplicationController
> def list
> @customers = Customer.find_all
> end
> end
>
>
> ... and Ajaxed link to get the customers,
>
> <%= link_to_remote "Get customers",
> :url=>{
> :controller=>"customers",
> :action=>"list",
> :complete=>"setCustomers( ''what should i put here
????'' )"
> %>
>
> I want to populate the javascript array with the response of the Ajax
> call to my CustomersController. The javasript callback function
> ''setCustomers'' gets called but I do not know how to pass
customers as a
> parameter?
>
> Can you help me?
--
Posted via http://www.ruby-forum.com/.