I get an error when trying to parse JSON from an HTML data attribute. This divI want to parse JSON from:
echo '<div class="udropdown" data-elements=\'{"option1" : "1", "option2" : "2" }\'></div>';
and this is part of jQuery (it is pushed, so $(this)necessary)
var ele = jQuery.parseJSON($(this).data('elements'));
but I keep getting this error:
Untrained SyntaxError: Unexpected Token o
source
share