Javascript examples for jQuery Method and Property:param
The param() method serializes an array or an object to use the data in the URL query string when making an AJAX request.
Parameter | Require | Description |
---|---|---|
object | Required. | 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:
<!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>