jQuery | param() Method

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

Syntax:

$.param( object, trad )

Parameters: This method accepts two parameters as mentioned above and described below:



  • object: It is a mandatory parameter which is used to specify an array or object to serialize.
  • trad: It is an optional parameter and used to specify whether or not to use the traditional style of param serialization.

Example 1: This example use param() method to create serialized representation of an object.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head
    <title>
        jQuery param() Method
    </title>
      
    <script src=
    </script>
</head
  
<body style="text-align:center;">
      
    <h1 style = "color:green;" >  
        GeeksForGeeks
    </h1>  
      
    <h2>jQuery param() Method</h2>
  
    <button>Click</button>
      
    <div></div>
      
    <!-- Script using param() method -->
    <script>
        $(document).ready(function() {
              
            personObj = new Object();
              
            personObj.Firstword = "Geeks";
            personObj.Secondword = "For";
            personObj.Thirdword = "Geeks";
            personObj.Wordcolor = "Green"; 
              
            $("button").click(function() {
                $("div").text($.param(personObj));
            });
        });
    </script>
</body>
  
</html>  

chevron_right


Output:
Before click on the button:

After click on the button:

Example 2: This example use param() method to create serialized representation of an object.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head
    <title>
        jQuery param() Method
    </title>
      
    <script src=
    </script>
</head
  
<body style="text-align:center;">
      
    <h1 style = "color:green;" >  
        GeeksForGeeks
    </h1>  
      
    <h2>jQuery param() Method</h2>
  
    <button>Click</button>
      
    <div></div>
      
    <!-- Script using param() method -->
    <script>
        $(document).ready(function() {
              
            personObj = new Object();
              
            personObj.Fullword = "GeeksForGeeks ";
            personObj.Wordcolor = " Green"; 
              
            $("button").click(function(){
                $("div").text($.param(personObj));
            });
        });
    </script>
</body>
  
</html>  

chevron_right


Output:
Before click on the button:

After click on the button:



My Personal Notes arrow_drop_up

Small things always make you to think big

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.