From 9961b363abaf8dcd32694d55f6f2d756d247f6ff Mon Sep 17 00:00:00 2001
From: Richard Gibson The The The This method can act on a jQuery object that has selected individual form elements, such as This method can act on a jQuery object that has selected individual form controls, such as .serializeArray()
method creates a JavaScript array of objects, ready to be encoded as a JSON string. It operates on a jQuery object representing a set of form elements. The form elements can be of several types:.serializeArray()
method creates a JavaScript array of objects, ready to be encoded as a JSON string. It operates on a jQuery collection of form
s and/or form controls. The controls can be of several types:
<form>
<div><input type="text" name="a" value="1" id="a"></div>
@@ -29,7 +29,7 @@
</form>
.serializeArray()
method uses the standard W3C rules for successful controls to determine which elements it should include; in particular the element cannot be disabled and must contain a name
attribute. No submit button value is serialized since the form was not submitted using a button. Data from file select elements is not serialized.<input>
, <textarea>
, and <select>
. However, it is typically easier to select the <form>
tag itself for serialization:<input>
, <textarea>
, and <select>
. However, it is typically easier to select the <form>
element itself for serialization:
$( "form" ).submit(function( event ) {
console.log( $( this ).serializeArray() );