I have an array in PHP, which I pack to JSON object with _json_encode(..)_ . Then I send it to JS function as parameter. When I want to parse the object in Javascript with eval(..) nothing happens (there is an error behind the curtains I guess). What could be wrong?
Code:
<script type="text/javascript">
function testFun(inArr) {
var obj=eval('('+inArr+')');
alert(obj.m); //alert(obj) also doesnt work
}
</script>
//PHP
$spola_array = array('m' => 1, 'z' => 2);
$json_obj=json_encode($spola_array);
echo '<script type="text/javascript">testFun('.$json_obj.');</script>';