[Catalyst] Catalyst::View::JSON sends a file
Toby Corkindale
toby.corkindale at strategicdata.com.au
Tue Jan 12 04:18:15 GMT 2010
Tomas Doran wrote:
>
> On 11 Jan 2010, at 23:29, Christoph Friedrich wrote:
>> just worked a little with Catalyst::View::JSON. But when I call some
>> action via Firefox that uses this View Firefox gives me a file to
>> download and don't show the json directly.
>> Is there a way to change this behavior? I want to see what I would get
>> as JSON and not download it ^^
>
> Your browser will do whatever it normally does with the mime type you're
> sending.
>
> By changing settings or mime types you'll probably be able to convince
> it to display the JSON.
You could also adjust the $c->response->content_type() to be 'text/plain'.
But watch out, as some javascript libraries decide what to do with the
response based on it's content-type, and will not JSON-decode what it
thinks is html or plain text.
> However, why not write a JSON debug view that pretty prints JSON
> responses inside an HTML page?
Definitely the better option.
Or learn to get into the Firefox or Chrome javascript debuggers.. well
worth having that skill.
Toby
More information about the Catalyst
mailing list