Catalyst-View-JSON
view release on metacpan or search on metacpan
JSON use is still developing and has not been standardized. This section
provides some notes on various libraries.
Dojo Toolkit: Setting dojo.io.bind's mimetype to 'text/json' in the
JavaScript request will instruct dojo.io.bind to expect JSON data in the
response body and auto-eval it. Dojo ignores the server response
Content-Type. This works transparently with Catalyst::View::JSON.
Prototype.js: prototype.js will auto-eval JSON data that is returned in
the custom X-JSON header. The reason given for this is to allow a
separate HTML fragment in the response body, however this of limited use
because IE 6 has a max header length that will cause the JSON evaluation
to silently fail when reached. The recommend approach is to use
Catalyst::View::JSON which will JSON format all the response data and
return it in the response body.
In at least prototype 1.5.0 rc0 and above, prototype.js will send the
X-Prototype-Version header. If this is encountered, a JavaScript eval
will be returned in the X-JSON response header to automatically eval the
response body, unless you set *no_x_json_header* to 1. If your version
of prototype does not send this header, you can manually eval the
lib/Catalyst/View/JSON.pm view on Meta::CPAN
section provides some notes on various libraries.
Dojo Toolkit: Setting dojo.io.bind's mimetype to 'text/json' in
the JavaScript request will instruct dojo.io.bind to expect JSON
data in the response body and auto-eval it. Dojo ignores the
server response Content-Type. This works transparently with
Catalyst::View::JSON.
Prototype.js: prototype.js will auto-eval JSON data that is
returned in the custom X-JSON header. The reason given for this is
to allow a separate HTML fragment in the response body, however
this of limited use because IE 6 has a max header length that will
cause the JSON evaluation to silently fail when reached. The
recommend approach is to use Catalyst::View::JSON which will JSON
format all the response data and return it in the response body.
In at least prototype 1.5.0 rc0 and above, prototype.js will send the
X-Prototype-Version header. If this is encountered, a JavaScript eval
will be returned in the X-JSON response header to automatically eval
the response body, unless you set I<no_x_json_header> to 1. If your
version of prototype does not send this header, you can manually eval
( run in 1.922 second using v1.01-cache-2.11-cpan-364913b4093 )