Getting unexpected token: n when parsing JSON in JavaScript
Grab innerHTMl of this div
<div style="display:none;" id="graphdata">{n:2 , e:1},{from:1 , to:2},{from:2, to:3},{from:3, to:4}</div> then parsing it with this js code
jdiv=document.getElementById('graphdata').innerHTML; edges=JSON.parse(jdiv); Chrome's JS console says: Uncaught SyntaxError: Unexpected token n
can't find out where this token n can be and what is wrong with my code? any ideas?
+6
2 answers