Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

Hello Experts,
I am fetching data in my controller from a web service
def search
response = @@api.DoSearch()
end
and in my .rjs template, I am doing
page.replace_html 'fields_chooser', :partial => 'fields_chooser'
,:locals =>{:response => response}
page.visual_effect(:Appear, 'fields_chooser')
and in _fields_chooser.rhtml, I want to use response. But I can't see
response in my .rhtml file.
what am I missing here? how do I pass data "response" from controller to
the .rhtml file or should I be doing this in a different way?
Thanks guys for any help.
PS

Pradeep Sethi wrote:
> Hello Experts,>> I am fetching data in my controller from a web service>> def search> response = @@api.DoSearch()> end>> and in my .rjs template, I am doing>> page.replace_html 'fields_chooser', :partial => 'fields_chooser'> ,:locals =>{:response => response}> page.visual_effect(:Appear, 'fields_chooser')
I haven't been able to get the :locals parameter to work in an RJS call
either, so what I've done in cases like this is to use an instance
variable. @response is a reserved attribute so you might try a
different variable name in such a case.
Jeff

The response variable that you have set
response = @@api.DoSearch()
is only local scope. When you enter your rjs, it has gone out of scope.
Use
@response = @@api.DoSearch()
and in the rjs
page.replace_html 'fields_chooser', :partial => 'fields_chooser'
,:locals =>{:response => @response}
page.visual_effect(:Appear, 'fields_chooser')
I think this should fix it.