I've did some testing with the latest versions: Firefox and Opera
download, Chrome and Safari display.

Setting web.header("Content-Type", "text/plain") makes them all
display.

On Aug 18, 8:17 pm, Branko Vukelić <bg.bra...@gmail.com> wrote:
> On 2011-08-18 05:12 -0700, andrei wrote:
>
> > What headers are set?
> > In my app to return json I do this:
>
> > web.header("Content-Type", "application/json")
> > return json.dumps(result)
>
> AFAIK, if you set content type to proper JSON content type, the browser
> _will_ download the JSON response instead of dumping it into the window.
> To make it dump into the window, I think it's best to first check the
> _request_ header, and make sure it's not an XHR response, and then set
> the response Content-Type header to 'text/plain'. In case of XHR, you
> can leave it as 'application/json'.
>
> The incoming header to check is 'HTTP_X_REQUESTED_WITH', which should be
> set to 'XMLHttpRequest'. You set the response content-type to text/plain
> if the header is either missing or set to something else than
> 'XMLHttpRequest'. I forgot the exact API for getting the headers, but
> I'm sure you already know how to get them.
>
> --
> Branko Vukelic
> bra...@herdhound.com
> bg.bra...@gmail.com
>
> Lead Developer
> Herd Hound (tm) - Travel that doesn't bitewww.herdhound.com
>
> Love coffee? You might love Loveffee, too.
> loveffee.appspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com.
To unsubscribe from this group, send email to 
webpy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to