mikong
2008-Mar-05 09:21 UTC
Content-type when using format.js { render :json => @person }
The current behavior is that the response content-type is javascript. Is this expected or should the content-type be json? I''m doing an ajax request (that''s why it''s format.js) which expects a json response. Or did I miss setting something in the request header and should have used format.json? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Assaf Arkin
2008-Mar-05 09:33 UTC
Re: Content-type when using format.js { render :json => @person }
On Wed, Mar 5, 2008 at 1:21 AM, mikong <michaelgalero@gmail.com> wrote:> > The current behavior is that the response content-type is javascript. > Is this expected or should the content-type be json? I''m doing an ajax > request (that''s why it''s format.js) which expects a json response. Or > did I miss setting something in the request header and should have > used format.json?.js is short for JavaScript, and that''s the content type you''re requesting. -- Assaf http://labnotes.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
mikong
2008-Mar-05 14:34 UTC
Re: Content-type when using format.js { render :json => @person }
Sorry about that, I had the wrong impression that respond to format.js simply meant responding to an ajax request. So I missed setting the HTTP Accept header to ''application/json'' to use format.json. Thanks On Mar 5, 5:33 pm, "Assaf Arkin" <as...@labnotes.org> wrote:> On Wed, Mar 5, 2008 at 1:21 AM, mikong <michaelgal...@gmail.com> wrote: > > > The current behavior is that the response content-type is javascript. > > Is this expected or should the content-type be json? I''m doing an ajax > > request (that''s why it''s format.js) which expects a json response. Or > > did I miss setting something in the request header and should have > > used format.json? > > .js is short for JavaScript, and that''s the content type you''re requesting. > > -- Assafhttp://labnotes.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---