Functions used with jqueryserializeArray () to facilitate the submission of forms _ jquery

Source: Internet
Author: User
Functions used together with jqueryserializeArray () are mainly used to conveniently submit forms. For more information, see. . SerializeArray () serializes table elements (similar to the '. serialize ()' method) and returns JSON data structure data. (From the jquery document ).
There is a form window with the code:

The Code is as follows:




JavaScript code Processing Form:

The Code is as follows:


Script
$ (Function (){
$ ("# Butsubmit"). click (function (){
Var data = convertArray ($ ("# tf"). serializeArray ());
$. Post (url, data, function (d) {}, "json ");
});
})
Function convertArray (o) {// mainly recommends this function. It converts the serialized value of jquery into the name: value format.
Var v = {};
For (var I in o ){
If (typeof (v [o [I]. name]) = 'undefined') v [o [I]. name] = o [I]. value;
Else v [o [I]. name] + = "," + o [I]. value;
}
Return v;
}
Script

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.