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

I want to store a json object into a hidden input for submit and send to server side. <input type=&#

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));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743763134a4503003.html

相关推荐

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

    I want to store a json object into a hidden input for submit and send to server side. <input type=&#

    6天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信