I need to send a serialized data as parameter in a javascript function as shown below.
<input type="button" id="btn1" onclick="fncname('{"data":"testval"}';)">
I am getting error unterminated string constant.
Can anyone help me to find out a solution for this?
You'll have to html encode your attribute to avoid conflicting quotes.
<input type="button" id="btn1" onclick="fncname('{"data":"testval"}')">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.