Jquery param ()
The jQuery. param () function is used to serialize a JS array or object into a string value. The jquery object is serialized as a URL parameter by name/value or key/value and connected. Used for URL query strings or AJAX requests. Syntax $. param (object, trad) parameter description object: required. Specifies the array or object to be serialized. Trad: Optional. Boolean value that specifies whether to use the traditional style serialized by parameters. Instance
Var v1 = $. param (true); // "" var v2 = $. param (100); // "" var v3 = $. param (12.34); // "" var v4 = $. param (""); // "" var v5 = $. param (function () {return 18 ;}); // "" var v6 =$. param (// \ d +/); // "" var v7 = $. param (new Date (); // "var v8 = $. param (null); // error var v9 = $. param (undefined); // error // The string will be treated as a character array var v10 = $. param ("name"); // "0 = n & 1 = a & 2 = m & 3 = e" var v11 = $. param ({name: "CodePlayer", age: 18}); // "name = CodePlayer & age = 18" var array = [{name: "name", value: "Michael" },{ name: "age", value: 18, extra: "ignore this attribute" },{ name: "grade"}, // No value attribute, the value is undefined and will be converted into an empty string "" {name: "orderId", value: 2 },{ name: "orderId", value: 3},]; var v12 = $. param (array ); // "name = % E5 % BC % A0 % E4 % B8 % 89 & age = 18 & grade = & orderId = 2 & orderId = 3" // jQuery splits each of the arrays elements are treated as objects, and call its name and value Attributes // since these elements do not have the name attribute, they are undefined and converted to the string "undefined" // since these elements do not have the value attribute, they are undefined, and is converted into an empty string "" var v13 = $. param (["name", 2, 3]); // "undefined = & undefined ="