jquery Ajax uses serialize () to cause problems with too many form fields

Source: Internet
Author: User

jquery Ajax using Serialize () Form field too many fields can not send all, instead of using the Serializearray () method, and then check the use of the method, there is no problem for the time being found

  such as: {Name: ' Extract heavenly Stars ', Position: ' It technology '}// PS: note put the same name in an array Function getformjson (form)  {   var o = {};  var a = $ (Form). Serializearray ();   $.each (a, function  ()  {    if  (o[this.name] !== undefined)  {       if  (!o[this.name].push)  {         o[this.name] = [o[this.name]];      }       o[this.name].push (this.value | |   ");     } else {      o[this.name] =  this.value | |   ";     }  });   return o;} Debug Calls  $ (function () {  $ ("#button"). Click (function () {    alert (Getformjson (" #formID "));   }); /ajax Submit $.ajax ({  type:  "POST",   uRL: "ajax.php",   data:getformjson ($ ("#formID")),///form data JSON Format function parameter fill in the form ID or form to be submitted   datatype:   ' JSON ',   success: function (msg)  {alert (msg)},  error: function (Error {alert (error);}});

Code Source: Http://www.tuicool.com/articles/NJFnEnz

jquery Ajax uses serialize () to cause problems with too many form fields

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.