Hi,
This group is defunct (although it''s worth searching the archives).
Please see the new better-named, spam-free, moderated group here:
http://groups.google.com/group/prototype-scriptaculous
Note that it''s moderated, so your first post won''t show up
immediately. Please be patient.
--
T.J. Crowder
tj / crowder software / com
On Aug 10, 9:35 pm, Transistor
<transistor....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi everyone.
> I love JSON and using Prototype has help me reduce the code to handle
> AJAX responses.
> But one thing keeps me confused and sometimes even frustrated.
> I don''t really understand what is going on with the headers, so if
> someone could take some time to explain what is going on, I (and
> probably a lot more people) would be very thankful.
> The thing is this. On my local server (Mac OS Leopard Server 10.5.4,
> PHP 5.2.5 by entropy.ch, Apache 2.2 Apple''s default) after trying
> different approaches, I finally got JSON to work using this:
> <?php
> $json = json_encode($status);
> header(''X-JSON:(''.$json.'')'');
> ?>
> and my javascript to handle the JSON response:
> onSuccess: function(transport,json) {
> Beautiful, works great, on my Mac at least
>
> When I upload this to the server, it doesn''t work.
> I don''t know what kind of machine it is, but it is running PHP
5.2.0
> and Apache 2.2 and probably Linux.
> After a few hours of searching on the net and trial/error, this
> worked:
> <?php
> $json = json_encode($status);
> header(''Content-type: application/json'');
> echo $json;
> ?>
> And the javascript:
> onSuccess: function(transport) {
> var json = transport.responseText.evalJSON();
>
> So, anyone knows WHY? I would really like to understand what is going
> on here.
> Thank you.
> Joe
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---