Home >>jQuery Tutorial >jQuery $.param() Method
The $.param() method in jQuery is used to creates a serialized representation of an array or an object values can be used in the URL query string when making an AJAX request.
Syntax:$.param(object,trad)
Parameter | Description |
---|---|
object | It is a Required parameter and is used to specifies an array or object to serialize |
trad | It is an Optional parameter and is used to a Boolean value specifying whether or not to use the traditional style of param serialization |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
personObj = new Object();
personObj.firstname = "Mohan";
personObj.lastname = "Kumar";
personObj.age = 25;
personObj.eyecolor = "Brown";
$(".btn1").click(function(){
$(".div1").text($.param(personObj));
});
});
</script>
</head>
<body>
<button class="btn1">Click me to Get Serialize object</button>
<div class="div1"></div>
</body>
</html>