i have array in php, and i need work with this array in jQuery. What best way send array( or variable ) from php to jQuery? Thanks
2 Answers
json_encode() (PHP >= 5.2) is arguably the easiest way.
$array_js = json_encode($array);
echo "<script type='text/javascript'> my_array = ".$array_js."; </script>";
1 Comment
Aaron W.
If you're (PHP < 5.2), I've had success with the jsonwrapper script. boutell.com/scripts/jsonwrapper.html