将表单转成JSON提交:jquery html json forms
draft 的一个jQueyr实现,用于将表单转成JSON格式提交。
用法:
Include the script in your page and any form with an attribute of enctype set to 'application/json' will submit data with a json payload.
<form enctype='application/json'> <input name='places[0][city]' value='New York City'> <input type='number' name='places[0][population]' value='8175133'> <input name='places[1][city]' value='Los Angeles'> <input type='number' name='places[1][population]' value='3792621'> <input name='places[2][city]' value='Chicago'> <input type='number' name='places[2][population]' value='2695598'> </form>
produces
{ "places": [ { "city": "New York City", "population": 8175133 }, { "city": "Los Angeles", "population": 3792621 }, { "city": "Chicago", "population": 2695598 } ] }
To disable json post submission, call $.JSONform.disable()
.
To enable, $.JSONform.enable()
.
Call $(formElement).JSONencode()
to get a JSON object representing formElement.
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!