Displaying 1 result from an estimated 1 matches for "tags_list".
Did you mean:
tag_list
2011 Aug 25
7
How to safely embed JSON object in HTML document
...le. Something like this:
<% tags = [{name:"tag1", color:"green"}, {name:"</script><b>I can do
something bad here</b>", color:"red"}] %>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
var tags_list = <%= tags.to_json %>;
// ]]>
</script>
However, this escapes all the double quotes in that string, which
triggers a "SyntaxError: Unexpected token &" in Chrome:
var tags_list =
[{"name":"tag1","color":"...