最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set a json object to the hidden input - Stack Overflow

programmeradmin2浏览0评论

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 :

$('#permissions').val(json_object);

Share Improve this question asked Jun 24, 2015 at 20:02 Behzad AzizanBehzad Azizan 2611 gold badge6 silver badges14 bronze badges 1
  • $('input[name="permissions"]').val(json_obj'); – msg Commented Jun 24, 2015 at 20:07
Add a ment  | 

1 Answer 1

Reset to default 11

Use JSON.stringify like

$('#permissions').val(JSON.stringify(json_object));
发布评论

评论列表(0)

  1. 暂无评论