received an array from the database. You need to process it in JavaScript. Help)
& lt;? php
$ ID1 = Array ("id" = & gt; "1", "name" = & gt; "block");
$ json = json_encode ($ ID1);
? & gt;
& lt; script & gt;
var id1 = json.parse (& lt;? php echo $ json;? & gt;);
& lt; / script & gt;
// What am I doing wrong to use JSON format?
Answer 1, Authority 100%
as an option Try to wrap the output in quotes;
& lt; script & gt;
var id1 = json.parse ('& lt; php echo $ json;? & gt;);
& lt; / script & gt;
Answer 2
And as an option is just purely with Masiva
var id1 = & lt;? PHP Print_R ($ ARR); ? & gt ;;