I have an array in php like this:
$array_php = (1,2,3,4,5);
In JavaScript I do:
var obj = <?php echo json_encode($array_php); ?>;
If I do alert(obj); I get the content well without problems: 1,2,3,4,5
If I do:
var elem = obj.split(',');
This fail. If I do alert(elem[1]) for example I don't get anything. And the line var elem = ... fails.
If I create the array without json_enconde works fine, but I need access to this object.
What can I do? Thanks!
var obj = JSON.parse(<?php echo json_encode($array_php); ?>);.objusingarr = $.pareseJSON(obj), accessing each object in aforloop!JSON.parse([1,2,3,4,5])which triggerstoStringon the array giving usJSON.parse("1,2,3,4,5"), which fails because"1,2,3,4,5"is invalid JSON.)