jQuery param()

Introduction

Output the result of a serialized object:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from  ww w. ja v a  2s. com
<script>
$(document).ready(function(){
  personObj = new Object();
  personObj.firstname = "CSS";
  personObj.lastname = "HTML";
  personObj.age = 123;
  personObj.eyecolor = "blue";
  $("button").click(function(){
       $("div").text($.param(personObj));
  });
});
</script>
</head>
<body>

<button>Serialize object</button>

<div></div>

</body>
</html>

The param() method creates a serialized representation of an array or an object.

The serialized values can be used in the URL query string.

$.param(object,trad)
Parameter
Optional
Description
object
Required.
an array or object to serialize
trad
Optional.
A Boolean value specifying whether to use the traditional style of param serialization



PreviousNext

Related