[nycphp-talk] PHP to ajax variable passing problem

Cliff Hirsch cliff at
Thu Aug 9 15:37:47 EDT 2007

On 8/9/07, Cliff Hirsch <cliff at> wrote:
>> My Ajax response handler uses this line, which is fairly typical:
>> var output = req.responseText;
>>> >From php, I'm echoing back json. Example: {"status":1,"count":0,"data":""}
>> But instead of var output being an object, it is a string:
>> "{"status":1,"count":0,"data":""}"
>> How do I make this an object?
>> Cliff 

As usual, figured it out minutes after my post. Answer for the group:

From: var output = req.responseText;
To:     var output = eval('('+req.responseText+')');

Better answer ‹ don¹tr try to reinvent the wheel. Yeah but we can¹t help
ourselves. Xajax looks very cool....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list