JQuery serialize () serializeArray (), jquery form serialization
1. serialize () method
Format: var data = $ ("form"). serialize ();
Function: serialize the form content into a string.
In this way, when submitting form data through ajax, you do not
The Ajax serialize () form is serialized to upload files and serialize is serialized.
Upload files using the traditional form submission method
upload a file:
However, the traditional form submission will refresh the page, but in some cases,
1.serialize () methodFormat: var data = $ ("form"). Serialize ();Function: Serializes the contents of the form into a single string.This way, when Ajax submits the form data, it is not necessary to enumerate each parameter. Simply set the data
The serialize () serialization of jquery is a simple introduction:In jquery, when using Ajax, it is often necessary to assemble input data to be sent to the server in the form of a key-value pair (key/value).The Serialize method can do this easily,
In jquery Ajax, data is sent to the server in the form of a key-value pair (Key/value), which can be serialized as a key-value pair using the jquery Ajax Serialize () method form when submitting form data using AJAX (key1=value1&key2= Value2 ... )
When submitting a form through jquery Ajax, the form content is usually obtained in the following way.varform = ' Add-account-form '; //form ID $ (' # ' + form). Submit (function() {varAccount = { ' user_id ': ',
In jquery, we can directly use serialize () to convert ajax submitted forms. In this way, the input in the form name is converted to the get method. If we have a large number of parameters, we do not need to fill them out.
Data in jQuery ajax is
Serialized data
--Example program: memo
Create a new single-document SDI application. Select cformview for the View class so that you can enter it in the window. Create three edit boxes on the page, and then add three corresponding edit box
This article: In jquery, when we use Ajax, we often need to assemble input data in the form of key-value pairs (Key/value) to the server, with the jquery serialize method can easily complete this work, Use this method to serialize the form to a
Example Analysis of serialize () usage in JQuery
This article mainly introduces the usage of serialize () in JQuery. The example analyzes the functions, definitions, and related usage skills of the serialize () method. For more information,
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.