jQuery param() method (original) (raw)
Last Updated : 11 Jul, 2023
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 that is used to specify an array or object to serialize.
- **trad: It is an optional parameter and is used to specify whether or not to use the traditional style of param serialization.
****Example 1:**uses This example uses the param() method to create a serialized representation of an object.
html `
jQuery param() Method<script src=
<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 () {
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">"</mi><mi>d</mi><mi>i</mi><mi>v</mi><mi mathvariant="normal">"</mi><mo stretchy="false">)</mo><mi mathvariant="normal">.</mi><mi>t</mi><mi>e</mi><mi>x</mi><mi>t</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">("div").text(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">"</span><span class="mord mathnormal">d</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">"</span><span class="mclose">)</span><span class="mord">.</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">t</span><span class="mopen">(</span></span></span></span>.param(personObj));
});
});
</script>
`
**Output:
****Example 2:**This example uses the param() method to create a serialized representation of an object.
html `
jQuery param() Method<script src=
<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 () {
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">"</mi><mi>d</mi><mi>i</mi><mi>v</mi><mi mathvariant="normal">"</mi><mo stretchy="false">)</mo><mi mathvariant="normal">.</mi><mi>t</mi><mi>e</mi><mi>x</mi><mi>t</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">("div").text(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">"</span><span class="mord mathnormal">d</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">"</span><span class="mclose">)</span><span class="mord">.</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">t</span><span class="mopen">(</span></span></span></span>.param(personObj));
});
});
</script>
`
**Output: