Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Prototype, JSON and headers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Transistor  
View profile  
(1 user)  More options Aug 10 2008, 4:35 pm
From: Transistor <transistor....@gmail.com>
Date: Sun, 10 Aug 2008 13:35:31 -0700 (PDT)
Local: Sun, Aug 10 2008 4:35 pm
Subject: Prototype, JSON and headers
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
T.J. Crowder  
View profile  
 More options Aug 11 2008, 3:41 am
From: "T.J. Crowder" <t...@crowdersoftware.com>
Date: Mon, 11 Aug 2008 00:41:49 -0700 (PDT)
Local: Mon, Aug 11 2008 3:41 am
Subject: Re: Prototype, JSON and headers
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....@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google