Serializearray () and serialize ()

Source: Internet
Author: User

 

Serialize () The table contents of the sequence table are strings for Ajax requests.

Serializearray () Serializes tabular elements (similar to the '. Serialize () ' method) to return the JSON data structure.


. Serializearray ()

Encodes a set of form elements as an array of "Name attribute value/value property value". JSON structure, such as:
[  {    name:a    1  },  {    name:b    2  },  {    name:c    3  },  {    name:d    4  },  {    name:e    5  }] . Serialize ()


Encodes a set of form elements as a filled string. The string is a standard URL encoding. Such as:
A=1&b=2&c=3&d=4&e=5
<form> <!--can be extracted by JSON array, URL string data type--<input type= "text" Name= "a" value= "1" id= "a"/> <inp UT type= "text" name= "B" value= "2" id= "B"/> <input type= "hidden" name= "C" value= "3" id= "C"/> <textarea Name= "D" rows= "8" cols= ">4</textarea> <select name=" E "> <option value=" 5 "selected=" sel ected ">5</option> <option value=" 6 ">6</option> <option value=" 7 ">7</op tion> </select> <input type= "checkbox" Name= "F" value= "8" id= "F1" checked= "checked"/> &    Lt;input type= "checkbox" Name= "F" value= "9" id= "F2"/> <input type= "Radio" name= "G" value= "ten" id= "G1"/> <input type= "Radio" name= "G" value= "one" checked= "checked" id= "G2"/> <input type= "password" name= "H" maxl Ength= "8" value= "H"/> <!--can not be extracted by JSON, URL string data type--<input type= "Submit" name= "I" value= "Submi T "id=" I "/> &Lt;input type= "button" Name= "J" value= "click Me" onclick= "msg ()"/> <input type= "file" Name= "K"/><br/ > <input type= "reset" value= "reset" name= "L"/> <input type= "image" Src= "/i/eg_submit.jpg" alt=     "Submit"/></form><p><tt id= "Results" ></tt></p><script>functionshowvalues () {varFields = $ (": Input"). Serializearray (); $("#results"). empty (); Jquery.each (Fields,function(i, field) {$ ("#results"). Append (Field.value + "");    }); }    $(": CheckBox,: Radio"). Click (showvalues); $("Select"). Change (ShowValues); ShowValues ();</script><script>functionshowvalues () {varstr = $ ("form"). Serialize (); $("#results"). text (str); }    $(": CheckBox,: Radio"). Click (showvalues); $("Select"). Change (ShowValues); ShowValues ();</script>

Serializearray () and serialize ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.