I want to access the following array @names in my java script as json format.
So in my controller I have this code:
def new
@release = Release.new
@names=User.select(:name).where("name LIKE 'sr%'")
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @release }
format.json { render :json =>{ :data1 => @names} }
end
end
Please let me know how to access the data1 in my view file and how to pass the value to the javascript function .
Thanks,
Ramya.
If you use jQuery, you can do:
You do :
But you should do:
Or: