JQuery Ajax-serializearray () method

Source: Internet
Author: User

Definition and usage

The Serializearray () method creates an array of objects (names and values) by serializing the form values.

You can select one or more form elements (such as input and/or textarea), or the form element itself.

Grammar

$ (selector). Serializearray ()

Detailed description

The Serializearray () method serializes the form element and returns the JSON data structure.

Note: This method returns a JSON object rather than a JSON string . You need to use a plug-in or a third-party library for string operations, such as:

var forminfo = $ (' #contextFrom '). Serializearray ();

FormInfo = $.tojson (forminfo).

The returned JSON object consists of an array of objects, each of which contains one or two name-value pairs of the--name parameter and the value parameter if value is not empty. For example:

[{name: ' FirstName ', Value: ' Hello '}, {name: ' LastName ', Value: ' World '}, {name: ' Alias '},//value is empty]

The. Serializearray () method uses the standard of the successful controls (active control) to detect which elements should be included. Specifically, the element cannot be disabled (disabled elements are not included), and the element should have a name attribute. The value of the Submit button is also not serialized. The data for the file selection element is also not serialized.

JQuery Ajax-serializearray () method

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.