param() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:param

jQuery param() Method

Description

The param() method serializes an array or an object to use the data in the URL query string when making an AJAX request.

Syntax

Parameter RequireDescription
objectRequired. an array or object to serialize
trad Optional. A Boolean value, whether to use the traditional style of param serialization

The following code shows how to Output the result of a serialized object:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    personObj = new Object();
    personObj.firstname = "Mary";
    personObj.lastname = "Bond";
    personObj.age = 20;//w ww. ja va 2s  .  co  m
    personObj.eyecolor = "blue";
    personObj.job = "programmer";

    $("button").click(function(){
        $("div").text($.param(personObj));
    });
});
</script>
</head>
<body>

<button>Serialize object</button>

<div></div>

</body>
</html>

Related Tutorials