jQuery Misc param() Method

jQueryWeb DevelopmentFront End Technology

The param() method in jQuery is used to create a serialized representation of an array or object.

Syntax

The syntax is as follows −

$.param(obj, val)

Above, obj is the object to serialize, whereas Val specifies whether or not to use the traditional style of param serialization.

Example

Let us now see an example to implement the jQuery param() method

 Live Demo

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      ob = new Object();
      ob.stdid = "S01";
      ob.roll = 3;
      $("button").click(function(){
         $("p").text($.param(ob));
      });
   });
</script>
</head>
<body>
<h2>Student Details</h2>
<p></p>
<button>Serialized Representation</button>
</body>
</html>

Output

This will produce the following output−

Click on the button to get serialized representation−

raja
Published on 30-Dec-2019 12:39:42
Advertisements