0

I guess I am looking for a best method of passing values: arrays, objects, JSON -- any data -- from PHP to javascript.

So far I've just seen:

   PHP - json_encode(value); 
   Javascript - eval()

and a variation of that by using json2.js or the alike.

1
  • yep... you pretty much got it... although I'd recommend the json2.js method. Commented Apr 26, 2011 at 20:30

1 Answer 1

3

PHP has:

JavaScript (json2.js) has:

  • JSON.stringify --> encode
  • JSON.parse --> decode
Sign up to request clarification or add additional context in comments.

1 Comment

jerone's got it. Don't use eval() in javascript for the data you are parsing, its a security problem: json.org/js.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.