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
$.post, $.get is a simple method, if you want to deal with complex logic, still need to use the Jquery.ajax ()I. General format of $.ajax$.ajax ({Type: ' POST ',URL: URL ,Data: data ,Success: Success ,DataType: dataType});Second, the parameter
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 ... )
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
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
Sometimes we need to use AJAX to submit the value of form, so we need to use serialize () to get the value of the form, but the value obtained if there is Chinese, will be garbled, the reason and solution is as follows:
Reason:. Serialize ()
A Brief Introduction to serialize () serialization of jQuery, jqueryserialize
A Brief Introduction to serialize () serialization of jQuery:
In jQuery, when ajax is used, the input data is often assembled and sent to the server in the form of
Reprinted from: http://blog.csdn.net/zqtsx/article/details/28655717Original form form value acquisition method (manual):[JavaScript]View PlainCopy
$.ajax ({
Type: "POST",
URL: "ajax.php",
Data: "name= the star &position=it
The form submission method used in the previous project. The form () method can be used to separate the submission event from the submit button and bind it to any event, the following is a good example. You can refer to the form submission method
Example of serialize (), serializeArray (), And param () methods in JQuery: serializearray
The following is the jsp code of the server:
"+username+" : "+content+" "); %>
Like other methods in JQuery, The serialize () method also acts on a JQuery
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.