九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
jquery.serializeJSON抓取數(shù)據(jù)

jquery.serializeJSON

Adds the method .serializeJSON() to jQuery (or Zepto) that serializes a form into a JavaScript Object, using the same format as the default Ruby on Rails request params.

Install

Install with bower bower install jquery.serializeJSON, or npm npm install jquery-serializejson, or just download the jquery.serializejson.js script.

And make sure it is included after jQuery, for example:

<script type="text/javascript" src="jquery.js"></script><script type="text/javascript" src="jquery.serializejson.js"></script>

Usage Example

HTML form:

<form>  <input type="text" name="title" value="Finding Loot"/>  <input type="text" name="author[name]" value="John Smith"/>  <input type="text" name="author[job]"  value="Legendary Pirate"/></form>

JavaScript:

$('form').serializeJSON();// returns =>{  title: "Finding Loot",  author: {    name: "John Smith",    job: "Legendary Pirate"  }}

Form input, textarea and select tags are supported. Nested attributes and arrays can be specified by using the attr[nested][nested] syntax.

HTML form:

<form id="my-profile">  <!-- simple attribute -->  <input type="text" name="fullName"              value="Mario Izquierdo" />  <!-- nested attributes -->  <input type="text" name="address[city]"         value="San Francisco" />  <input type="text" name="address[state][name]"  value="California" />  <input type="text" name="address[state][abbr]"  value="CA" />  <!-- array -->  <input type="text" name="jobbies[]"             value="code" />  <input type="text" name="jobbies[]"             value="climbing" />  <!-- nested arrays, textareas, checkboxes ... -->  <textarea              name="projects[0][name]">serializeJSON</textarea>  <textarea              name="projects[0][language]">javascript</textarea>  <input type="hidden"   name="projects[0][popular]" value="0" />  <input type="checkbox" name="projects[0][popular]" value="1" checked />  <textarea              name="projects[1][name]">tinytest.js</textarea>  <textarea              name="projects[1][language]">javascript</textarea>  <input type="hidden"   name="projects[1][popular]" value="0" />  <input type="checkbox" name="projects[1][popular]" value="1"/>  <!-- select -->  <select name="selectOne">    <option value="paper">Paper</option>    <option value="rock" selected>Rock</option>    <option value="scissors">Scissors</option>  </select>  <!-- select multiple options, just name it as an array[] -->  <select multiple name="selectMultiple[]">    <option value="red"  selected>Red</option>    <option value="blue" selected>Blue</option>    <option value="yellow">Yellow</option>	</select></form>

JavaScript:

$('#my-profile').serializeJSON();// returns =>{  fullName: "Mario Izquierdo",  address: {    city: "San Francisco",    state: {      name: "California",      abbr: "CA"    }  },  jobbies: ["code", "climbing"],  projects: {    '0': { name: "serializeJSON", language: "javascript", popular: "1" },    '1': { name: "tinytest.js",   language: "javascript", popular: "0" }  },  selectOne: "rock",  selectMultiple: ["red", "blue"]}

The serializeJSON function returns a JavaScript object, not a JSON String. The plugin should probably have been called serializeObject or similar, but those plugins already existed.

To convert into a JSON String, use the JSON.stringify method, that is available on all major new browsers. If you need to support very old browsers, just include the json2.js polyfill (as described on stackoverfow).

var obj = $('form').serializeJSON();var jsonString = JSON.stringify(obj);
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Jquery將表單轉(zhuǎn)化成Json對(duì)象
jQuery ajax - serialize() 方法
php – 在Dropdown Selection上,如何從Database填充完整的表單字段
如何實(shí)現(xiàn)當(dāng)鼠標(biāo)點(diǎn)擊輸入框時(shí),輸入框內(nèi)的提示文字自動(dòng)消失
javascript控制復(fù)選框只能選擇兩項(xiàng)后,別的都選不上。
python測(cè)試開(kāi)發(fā)django-173.bootstrap實(shí)現(xiàn)table表格行內(nèi)編輯
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服