Today in the process of interacting with the background, found that PHP for the received post has a limit, beyond 1000 fields will not be able to receive, project requirements in the case without changing the PHP configuration through the front-end approach, through analysis and online some Daniel's data finally found a solution, The following is an introduction:
First, because the post data too much can cause PHP to be unable to receive, then the solution is to submit the form in the form of the data to be submitted to a JSON field to submit to the background, in order to other forms will also have this problem, the method is encapsulated as a jquery extension of a method:
1 //Submitbuttonid submit button id,formid form id,formurl form submission URL,2Setserializeform:function(Submitbuttonid, FormID, Formurl, Callback, CLICKFN)3 {4 if($.isfunction (CLICKFN))5 {6 CLICKFN ();7 }8 9 var$submitButton =$ (submitbuttonid);Ten$ (document). On (' Click ', Submitbuttonid,function(event) { One $submitButton. Val (v.submitting); A$submitButton. attr (' disabled ',true); - - //The Serializearray () method creates an array of objects by serializing the form values the //json.stringify serialization of arbitrary JavaScript values into JSON strings - varJsondata =$ (FormID). Serializearray (); - varJsonstr =json.stringify (jsondata); - +$.post (Formurl, {' Jsonstr ': Jsonstr},function(response) { - if(Response.result = = ' Success '){ +$submitButton. PopOver ({trigger: ' manual ', content:response.message, placement: ' Right '). PopOver (' show ')); A$submitButton. Next (' PopOver '). addclass (' popover-success ')); at if(response.locate) { -SetTimeout (function() {location.href = response.locate}, 1000); - } -}Else { -$submitButton. attr (' disabled ',false); - $submitButton. Val (v.saveorder); in - if($.type (response.message) = = ' object ') to { +$.each (Response.message,function(key, value) - { the varerrorobj = ' # ' +key; * varErrorlabel = key + ' Label '; $ Panax Notoginseng if(typeofValue = = ' String ' | | Object.prototype.toString.call (value). IndexOf (' Array ') >0) - { the varErrorcontent = $.type (value) = = ' String '? Value:value.join ('; ')); + varerrormsg = ' <span id= ' + Errorlabel + ' "for=" ' + key + ' "class=" Text-error Red ">"; AErrorMsg + =errorcontent; theErrorMsg + = ' </span> '; + } - Else $ { $ varErrorcontent = ' '; - for(varErrorinchvalue) - { theErrorcontent + =Value[error]; -Errorcontent + = '; 'Wuyi } theErrorcontent.replace ('. ‘,‘‘) - varerrormsg = ' <tr id= ' + Errorlabel + ' ><td colspan=13><span for= "' + key + '" class= "Text-error Red" > "; WuErrorMsg + =errorcontent; -ErrorMsg + = ' </span></td></tr> '; About } $ -$ (' # ' +errorlabel). Remove (); - - var$errorOBJ =$ (errorobj); A if($errorOBJ. Closest ('. Input-group '). length > 0) + { the$errorOBJ. Closest ('. Input-group ')). After (errormsg) - } $ Else if(Object.prototype.toString.call (value). IndexOf (' Object ') >0) the { the $errorOBJ. After (errormsg); the } the Else - { in $errorOBJ. Parent (). append (errormsg); the } the$errorOBJ. CSS (' Margin-bottom ', 0); About$errorOBJ. CSS (' Border-color ', ' #953B39 '); the if($errorOBJ [0].id.indexof (' products ') >= 0) the { the varindex = parseint ($errorOBJ. Index ("Tr[id *= ' products ']")-errorlabeltotal; +errorlabeltotal++; - var$actionItem = $ ('. Actionlist-item:eq (' +index+ ') '); the$actionItem. CSS (' margin-bottom ', ' 28px ');Bayi } the the$ (errorobj). Change (function() - { -$ (' # ' +errorlabel). Remove (); the }); the }); the}Else { the$submitButton. PopOver ({trigger: ' manual ', content:response.message, placement: ' Right '). PopOver (' show ')); -$submitButton. Next (' PopOver '). addclass (' Popover-danger ')); the functionDestroy () {$submitButton. PopOver (' Destroy '))} theSetTimeout (destroy,3000); the }94 } the if($.isfunction (callback))returncallback (response); the}, ' JSON '); the });98}
You only need to call this method in the following ways:
1 $.setserializeform (' #submitOrder ', ' #orderAjaxForm ', v.formurl);
Resolves an issue where PHP cannot receive more than 1000 post fields