JQuery-serialize () method for outputting serialized form values _ jquery

Source: Internet
Author: User
JQuery-serialize () Output serialized form values are common and practical at work, so I have collected and sorted them out. For more information, see. Instance
Output serialized form value results:

The Code is as follows:


$ ("Button"). click (function (){
$ ("P"). text ($ ("form"). serialize ());
});


Definition and usage
The serialize () method creates a URL encoded text string by serializing the form value.
You can select one or more form elements (such as input and/or text boxes) or form elements.
Serialized values can be used in URL query strings when an AJAX request is generated.

Syntax

The Code is as follows:


$ (Selector). serialize ()


Detailed description
The. serialize () method creates a text string encoded with a standard URL. Its operation object is a jQuery object that represents the form Element Set.

There are several types of form elements:

The Code is as follows:



The. serialize () method can operate jQuery objects that have selected individual form elements, such,And. However, selectThe serialization of tags is generally easier:$ ('Form'). submit (function (){Alert ($ (this). serialize ());Returnfalse;}); Output standard query string:A = 1 & B = 2 & c = 3 & d = 4 & e = 5Note: Only "successful controls" are serialized as strings. If the button is not used to submit a form, the value of the submit button is not serialized. To include the value of a form element in a sequence string, the element must use the name attribute.

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.