How to use param() Method in JQuery AJAX

In this article, I will explain use of param() Method in JQuery AJAX.
  • 1850

JQuery AJAX param() Method

  • param() method creates a serialized representation of an array or an object.
  • In param() method, the serialized values can be used in the URL query string when making an AJAX request.

Syntax

$(selector).param(object,trad)

  • object object is the Required parameter. it is determine an array or object to serialize

  • trad trad is the Optional parameter. A Boolean value use the traditional style of param serialization.

Example

 

The following example show the use of param() method.

 

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        personObj = new Object();

        personObj.firstname = "Dinesh";

        personObj.lastname = "Sharma";

        personObj.age = 35;

        personObj.eyecolor = "blue";

        $("button").click(function () {

            $("div").text($.param(personObj));

        });

    });

</script>

</head>

<body>

<h2>param() Method Example</h2>

<button>Click for Serialize object</button>

<div></div>

</body>

</html>

Output

param.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2013 dotNetheaven. All rights reserved.