NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP to ajax variable passing problem

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


On 8/9/07, Cliff Hirsch <cliff at pinestream.com> 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: <http://lists.nyphp.org/pipermail/talk/attachments/20070809/4b8fc38b/attachment.html>


More information about the talk mailing list