NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP to ajax variable passing problem

Dell Sala dell at sala.ca
Thu Aug 9 17:08:42 EDT 2007


On Aug 9, 2007, at 3:46 PM, csnyder wrote:

> On 8/9/07, Cliff Hirsch <cliff at pinestream.com> wrote:
>>
>>  As usual, figured it out minutes after my post. Answer for the  
>> group:
>>
>>  From: var output = req.responseText;
>>  To:     var output = eval('('+req.responseText+')');
>
>
> Yes eval(), which always makes me a little queasy, even though I know
> it's relatively safe. I wonder how many years we'll be waiting for a
> true json_decode() function to make it into general circulation?

json.org provides a json decoder for javascript. I've always used  
this instead of eval. This will only parse the json subset, and will  
fail for other arbitrary javascript.

http://www.json.org/js.html
http://www.json.org/json.js

-- Dell





More information about the talk mailing list