I want to be able to define a hash pair inside an html element as an attribute and then parse it into an object to be processed by javascript.
example:
<div id="test" mydata="{'xkey':'xval','ykey':'yval'}">
<script>
var mydata = JSON.parse($('#test').attr('mydata'));
console.log(mydata.xkey);
</script>
But the problem is it is not being converted into an object and the output is undefined.
How can I achieve this ??