# Prototype and application/json

**URL:** <https://www.ruby-forum.com/t/prototype-and-application-json/160780>\
**Category:** Rails\
**Created:** [February 19, 2009, 5:03pm UTC](https://www.ruby-forum.com/t/prototype-and-application-json/160780 "2009-02-19T17:03:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkeyten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@monkeyten](https://www.ruby-forum.com/u/monkeyten)\
**Post date:** [February 19, 2009, 5:03pm UTC](https://www.ruby-forum.com/t/prototype-and-application-json/160780/1 "2009-02-19T17:03:20Z")

</div>

I have a feeling I am doing something wrong here (the great thing with  
Rails is that when it gets difficult you can generally assume that to  
be the case!), so any comments are appreciated.

I have a link on a page that makes an XHR. I’d like to return a JSON  
object to the page which can then be eval’d and various bits of data  
used. I set up the routing to make sure the format came through as  
JSON ([http://xxx/xxx/xx.json](http://xxx/xxx/xx.json)) using :format, and the controller  
returns the JSON object. The problem is that that response is sent as  
‘application/json’, which is not a default accept header (so I end up  
with a 406 response).

Obviously I could adjust the response header to include that MIME  
type, but my guess is that I am doing something stupid here and have  
missed something - any ideas appreciated!
