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 :

$('#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));

本文标签: javascriptHow to set a json object to the hidden inputStack Overflow