JQuery SerializeArray()

jQuery serializeArray() method creates a JavaScript array of objects, ready to be encoded as a JSON string. It operates on a jQuery collection of forms and/or form controls.

Below the syntax of serializeArray().

$(selector).serializeArray();

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery serializeArray()</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
  $("#button").click(function() {
    var res = $("form").serializeArray();
    $.each(res, function(i, val) {
         $("#response").append(val.name  + " : " + val.value + " ");
     });
  });
});
</script>
</head>
<body>
 <div>
   <form name="" id="">
     <p>First Name <input type="text" name="first_name" value="" /gt;</p>
     <p>Last Name <input type="text" name="last_name" value="" /gt;</p>
   </form>
 </div>
 <button style="margin:0 0 10px 0;background:#e8e8e8;" class="btn" id="button">serializeArray</button><br /><br />
 <div id='response'></div>
 </body>
</html>