I am using php to json encode an array and then parse it with jQuery's $.evalJSON()
to use it in the client side
$test = array(
'Label' => array(
'id' => '021780000002703007764835',
'notes' => '<a id="test" href="javascript:void(0)">ici</a>'
)
);
When encoded to json from php it produces
{"Label":{"id":"021780000002703007764835","notes":"<a id=\"test\" href=\"javascript:void(0)\">ici<\/a>"}}
However, when using the below js code to decode it I get a js error
var test = $.evalJSON('<?= $test; ?>');
When I remove the html markup, it decodes it fine. However, I need the markup and I am sure there is a way to decode it properly.
Any ideas?
Thanks