admin管理员组文章数量:1345172
I want to store a json object into a hidden input for submit and send to server side.
<input type='hidden' id='permissions' name='permissions' />
During submission :
<input type='hidden' id='permissions' value='[{"1" : "deny", "2": "deny", "5" : "allow"}]' name='permissions' />
I used bellow line but not working :
$('#permissions').val(json_object);
I want to store a json object into a hidden input for submit and send to server side.
<input type='hidden' id='permissions' name='permissions' />
During submission :
<input type='hidden' id='permissions' value='[{"1" : "deny", "2": "deny", "5" : "allow"}]' name='permissions' />
I used bellow line but not working :
Share Improve this question asked Jun 24, 2015 at 20:02 Behzad AzizanBehzad Azizan 2611 gold badge6 silver badges14 bronze badges 1$('#permissions').val(json_object);
- $('input[name="permissions"]').val(json_obj'); – msg Commented Jun 24, 2015 at 20:07
1 Answer
Reset to default 11Use JSON.stringify like
$('#permissions').val(JSON.stringify(json_object));
本文标签: javascriptHow to set a json object to the hidden inputStack Overflow
版权声明:本文标题:javascript - How to set a json object to the hidden input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743763133a2534750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论