jQuery - serializeArray( ) Method



The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.

The JSON structure returned is not a string. You must use a plugin or third-party library to "stringify".


Here is the simple syntax to use this method −

$.serializeArray( )


Here is the description of all the parameters used by this method −

  • NA


Assuming we have following PHP content in serialize.php file −

if( $_REQUEST["name"] )
   $name = $_REQUEST['name'];
   echo "Welcome ". $name;
   $age = $_REQUEST['age'];
   echo "<br />Your age : ". $age;
   $sex = $_REQUEST['sex'];
   echo "<br />Your gender : ". $sex;

Following is a simple example a simple showing the usage of this method −

      <title>The jQuery Example</title>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
      <script type="text/javascript" language="javascript">
         $(document).ready(function() {
                  function(data) {
               var fields = $("#testform").serializeArray();
               jQuery.each(fields, function(i, field){
                  $("#stage2").append(field.value + " ");
      <p>Click on the button to load result.html file:</p>
      <div id="stage1" style="background-color:blue;">
         STAGE - 1
      <br />
      <div id="stage2" style="background-color:blue;">
         STAGE - 2
      <form id="testform">
               <td><input type="text" name="name" size="40" /></td>
               <td><input type="text" name="age" size="40" /></td>
               <td> <select name="sex">
                  <option value="Male" selected>Male</option>
                  <option value="Female" selected>Female</option>
               <td colspan="2">
                  <input type="button" id="driver" value="Load Data" />

This will produce following result −