I get an error when trying to parse JSON from a HTML data attribute. This is the div I want to parse JSON from:
echo '<div class="udropdown" data-elements=\'{"option1" : "1", "option2" : "2" }\'></div>';
and this is the jQuery part (it's on click, so $(this) is necessary)
var ele = jQuery.parseJSON($(this).data('elements'));
but I keep getting this error:
Uncaught SyntaxError: Unexpected token o
parseJSON()sincedata()will do the parsing internally