I am trying to define a pure JSON string as an argument in a Javascript function.
Below is the way I want to define it:
<a href="#" onclick="js_func('arg_1', 'arg_2', '{"key": "value"}'); return false">Link</a>
Firebug gives me an error alert: unterminated string literal, even when I escape the double-quotes on the JSON string.
How can I solve this?
Thanks.
return false
. can you put more than one command into an event like that? and no semicolon? im not 100% here so sorry if this is acceptable – jon_darkstar Jan 9 '11 at 7:14href
, or you can use "#". Withoutreturn false
(or equivalent), the first will cause a reload, and the second will cause a jump to the top of the page. – Matthew Flaschen Jan 9 '11 at 7:33