Jquery param ()

Source: Internet
Author: User

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 ="

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.