Displaying JSON response in view


#1

Dear all,

I’m totally new with Ajax and Rails. How do I display JSON objects
that I get from the controller to the view. Is there any way we can
display the JSON objects directly in the DOM, or do I have to
manipulate the DOM to place the JSON objects upon successful Ajax
call? I just hate having to do the latter. Please advice.

Thank you in advance.


#2

On 5 Feb 2009, at 23:02, Joshua P. wrote:

Dear all,

I’m totally new with Ajax and Rails. How do I display JSON objects
that I get from the controller to the view. Is there any way we can
display the JSON objects directly in the DOM, or do I have to
manipulate the DOM to place the JSON objects upon successful Ajax
call? I just hate having to do the latter. Please advice.

well you could just insert the json string into the dom, but i doubt
that your users will find

{“foo”: “bar”}

very informative. It’s up to you to construct some appropriate way of
displaying your data.

Fred