Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

jQuery | param() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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.




<!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>  


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.




<!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>  


Output:
Before click on the button:

After click on the button:


My Personal Notes arrow_drop_up
Last Updated : 21 Feb, 2019
Like Article
Save Article
Similar Reads
Related Tutorials