Serializing a form into a JSON object[JavaScript] View PlainCopyPrint?
jquery.prototype.serializeobject= function (){
var obj= New Object ();
$.each (this. Serializearray (),function(index,param) {
if (!( Param.name in obj) {
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
SerializeThe Sequence table table content is a string that is used for Ajax requests . Can be for the entire form, or only for a certain part.HTML Code:Results: Single Single2 Multiple Multiple2 Multiple3 check1 check2
Definition and usageThe 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).
Original addresshttp://blog.csdn.net/flashdelover/article/details/8185775jquery has method $.fn.serialize, which can serialize forms into strings, and there are methods to serialize the form to an array of $.fn.serializearray.If you need to
Transferred from: http://blog.csdn.net/csdnzhangtao5/article/details/52981541The serialize (), Serializearray () methods are all jquery user serialized forms, serialization of data values for AJAX submissionsIn Chrome's console we clearly see that
1. Serialize () methodDescription: Serializes the contents of the form to a string that is used for AJAX requests.Format: var data = $ ("form"). Serialize ();2.serializeArray () methodDescription: Serializes a FORM element (similar to the '.
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
1. Serialize () methodSyntax:$ (selector). Serialize ()The output serialized form string, the file upload control (for example: ) type of form data is automatically ignored, that is, does not appear in the serialization string.For example, there is
JQuery serialized form serialize () serializeArray ()
1. serialize () method
Description: serialized form content is a string used for Ajax requests.
Format: var data =$ (form). serialize ();
2. serializeArray () method
Description: serialized
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 current situation is that the backend uses the PHP Yii framework to return the data to the front end in view mode.
There is a form form that, by binding the OnClick event, requests the data fetched by PHP to another backend, the following
APIS commonly used in JQuery Ajax operations: Differences and usage of serializeArray, serialize, And param, jqueryui
When using JQuery for ajax encoding, these three APIs are often used. This article describes how to use these three APIs. The
The current situation is that the back-end uses the php yii framework to return data to the front-end in view mode. There is a form that binds the onclick event and sends the data requests obtained by php to another backend, that is, the following
. SerializeArray (); returns an Array
Description:Compile the value of the form Element Used for submission into an array consisting of name and value objects. For example, [{name: a value: 1}, {name: B value: 2},...], this method does not accept
The serialize () method also acts on a JQuery object. It can serialize the content of DOM elements into strings. The serializeArray () method serializes DOM elements instead of returning strings, the following jsp code of the server is returned for
Requirements: Submit data from a table to the background, usually for batch modificationPut all the data into the input property, set the name definition to be the relevant property of the object, use the Serializearray method of jquery to
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 ': ',
This article will introduce some usage of serialize (), serializeArray (), And param () methods in jQuery. I hope this article will help you.
Like other methods in JQuery, The serialize () method also acts on a JQuery object, which can serialize the
The serialize () method is also an object that acts on a jquery when more form elements are submitted, and it is able to serialize the contents of the DOM elements into strings for Ajax requests.The serialize () method creates a URL-encoded text
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.