While looking thru the brand new documentation i found myself
stumbling upon the X-JSON header "again" as being suggested for
automatic json evaluation within prototype.
I must say that this approach is bad. We should evaluate on content
type. It is simple to add and i wonder why no one else did it already.
The content-type "text/x-json" is the closest acceptable description
according to the RFCs and should be used by prototype to determine if
evaluation is in order. Just like text/javascript, which is
implemented already.
The whole reason behind this is, that a header line is limited to a
specific size. So if youre JSON data is to huge, the server will
return nothing (or refuse delivery.. i dont know exactly what happens
in the background - browser or server). I expirienced this in a
PHP/Apache enviroment.
We should stick to content types instead of "inventing" new headers
which are limited in size anyways..
This is what i added to make it work:
evalJSONResponse: function() {
try {
return eval('(' + this.transport.responseText + ')');
} catch (e) {}
},
respondToReadyState ...
[...]
if (this.header('Content-type') == 'text/x-json')
json = this.evalJSONResponse();
Opinions?
--
Kjell
-- www.m3nt0r.de
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---