# Displaying JSON response in view

**URL:** <https://www.ruby-forum.com/t/displaying-json-response-in-view/159581>\
**Category:** Rails\
**Created:** [February 6, 2009, 12:03am UTC](https://www.ruby-forum.com/t/displaying-json-response-in-view/159581 "2009-02-06T00:03:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [February 6, 2009, 12:03am UTC](https://www.ruby-forum.com/t/displaying-json-response-in-view/159581/1 "2009-02-06T00:03:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [February 6, 2009, 1:02am UTC](https://www.ruby-forum.com/t/displaying-json-response-in-view/159581/2 "2009-02-06T01:02:46Z")

</div>

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
