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.b...@gmail.com
Lead Developer
Herd Hound (tm) - Travel that doesn't bite
www.herdhound.com
Love coffee? You might love Loveffee, too.
loveffee.appspot.com
AFAIK, 'text/plain' would be the best bet if the intention is to simply
dump stuff for testing purposes.
--
Branko Vukelic
bra...@herdhound.com
bg.b...@gmail.com
Lead Developer
If course, that's the best way. What I meant is _if_ you simply want to
dump the contents into the browser window, then you need to use
text/plain as it works accross all browsers.
--
Branko Vukelic
bra...@herdhound.com
bg.b...@gmail.com
Lead Developer
I set the content type to "application/json" by default and change it
to "text/plain" if there is a query parameter text=true.
That makes it easier to debug in the browser.
Anand
Lol. It happens. :)