Jquery implements ajax form submission method summary, jqueryajax form submission
Method 1:
Obtain the required data elements separately. The form label is not used for the outer part of the DOM structure (applicable to scenarios where the amount of data is small and the data elements are scattered throughout the page)
$.ajax({ type: 'POST', url:'', data: { residence:[$('#region_1').val(),$('#region_2').val(),$('#region_3').val()], address:$('#address').val() }, dataType: 'json', success: function(data){ }, error:function(err){ } });
Method 2:
Form labels need to be wrapped (applicable to large data volumes and element sets)
Function AddHandlingFeeToRefund () {var AjaxURL = ".. /OrderManagement/AjaxModifyOrderService. aspx "; alert ($ ('# formAddHandlingFee '). serialize (); $. ajax ({type: "POST", dataType: "html", url: AjaxURL + '? Action = '+ 'submithandlinger' +' & OrderNumber = '+ $. trim ($ ("# <% = this.txt OrderNumber. clientID %> "). val (), data: $ ('# formAddHandlingFee '). serialize (), success: function (result) {var strresult = result; alert (strresult); // load the maximum refundable amount $ ("# spanMaxAmount" ).html (strresult );}, error: function (data) {alert ("error:" + data. responseText );}});}
Html code:
<Form id = "formaddhandling.pdf" name = "formaddhandling.pdf" enctype = "multipart/form-data" onsubmit = "AddHandlingFeeToRefund () "> <table id =" addhandling.pdf "class =" Wfill "> <tr> <td> <asp: literal ID = "UI_Amount" runat = "server" Text = "processing fee" meta: resourcekey = "HandlingFeeAmount"/> </td> <input type = "text" id = "txtHandlingFeeAmount" name = "txtHandlingFeeAmount" class = "{required: true, number: true} "maxlength =" 12 "/> </td> </tr> <td> <asp: literal ID = "UI_HandlingFeeType" runat = "server" Text = "meta" meta: resourcekey = "HandlingFeeHandlingFeeType"/> </td> <crmweb: htmlSelectControl ID = "HandlingFeeType" EnumTypeName = "DX. OMS. model. common. handlingFeeType, DX. OMS. model. common "EmptyValue =" "EmptyText =" Select "runat =" server "class =" text {required: true} "/> </td> </tr> <td> <asp: Literal ID =" UI_Notes "runat =" server "Text =" Remarks "meta: resourcekey = "HandlingFeeNotes"/> </td> <textarea id = "txtNotes" name = "txtNotes" class = "text {required: true} "cols =" 22 "rows =" 2 "maxlength =" 100 "> </textarea> </td> </tr> <td> </td> <td> <input id = "Submit1" type = "submit" value = "add processing fee"/> <asp: button ID = "Button1" runat = "server" Text = "add processing fee" OnClientClick = "javascript: AddHandlingFeeToRefund () "/> </td> </tr> </table> </form>