Try this:
//php
$myArray=array('status'=>1);
$jsonData=json_encode($myArray);
return $jsonData;
Dont forget the header.

//javascript/prototype
jsonResponse=eval('('+response.responseText+')');
Access data as array:
var myVal=jsonResponse[0].status;

Hope that helps

On 10/7/08, liketofindoutwhy <[EMAIL PROTECTED]> wrote:
>
> For some reason, no matter what I use
>
>       new Ajax.Request(url, {
>                       method: 'get',
>
>                       onSuccess: function(transport, json){
>                               //alert(Object.inspect(json));
>                               alert(json ? Object.inspect(json) : "no JSON 
> object");
>                       },
>                ...
>         });
>
> and then in PHP, when i use
>
> header('Content-type: application/x-json');
> echo '{ "status" : 1 }';
>
>
> the ajax will come back showing  "no JSON object"
>
> it doesn't matter if i use   text/x-json  or text/json or application/
> json
>
> and it is prototype 1.6.0.3...
> is there something wrong the header or the formatting of the content?
> thanks.
>
>
> >
>

-- 
Sent from Gmail for mobile | mobile.google.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to