Having an array
`Array
(
[0] => Array
(
[operative] => 2
[start] => 01:00:00
[end] => 13:00:00
[color] => 543939
)
[1] => Array
(
[operative] => 3
[start] => 08:00:00
[end] => 09:00:00
[color] => 52e612
)
)
`
need to change this into JSON so I use json_encode(), I get a string [{"operative":"2","start":" 01:00:00","end":" 13:00:00","color":"543939"},{"operative":"3","start":" 08:00:00","end":" 09:00:00","color":"52e612"}]
but when I am using JSON into JavaScript by function $.parseJSON() or JSON.parse(), both are giving me not defined.
ok I have used it like this
options1 = '[{"operative":"2","start":" 01:00:00","end":" 13:00:00","color":"543939"},{"operative":"3","start":" 08:00:00","end":" 09:00:00","color":"52e612"}]'
options1 = $.parseJSON(options1);
alert($.param(options1));
But alert is showing me undefined=&undefined=
console.log()it). Your json itself is valid, so$.parseJSON( data )should return an array if you are passing that string as an argument.var data = <?= json_encode($data) ?>;