Monday, January 7, 2013

[Rails] Re: JSON::ParserError in controller

Hi Jordon,
Thanks for your response.
I thought the JSON(response.body) performs the conversion of HTML->JSON.
But I also tried response.body.to_json which gave me the same error.
Will be great if you can explain a bit. Mean while I will also try using
nokigiri.

Thanks
Anush

Jordon Bedwell wrote in post #1091317:
> Hai,
>
> On Mon, Jan 7, 2013 at 3:01 AM, Anush J. <lists@ruby-forum.com> wrote:
> I call the above method in my controller and send @hash to view.
> In my browser I see the below error:
>
> JSON::ParserError in Original contentController#index
>
> 706: unexpected token at 'Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> And the rest of the page is printed without error in html format.
>
> It's printed out as HTML because it is HTML. HTML is not JSON and vice
> verse. If you wish to parse the page as it is you need to use something
> like Nokogiri so it gets tokenized, if you expected JSON you should
> contact them and ask them what went wrong.
>
> ---
>
> Jordon Bedwell
> http://envygeeks.com/
> https://twitter.com/envygeeks

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate