A summary of how jquery implements AJAX submission forms

Source: Internet
Author: User

Method One:

Get the required data elements separately, the DOM structure is not wrapped in the form label (for less data, data elements scattered throughout the page)

' POST ',   URL:',   data: {        residence:[$ (' #region_1 '). Val (), $ (' #region_2 '). Val (), $ (' # Region_3 '). Val ()],        address:$ (' #address '). Val ()   },   ' json ',     function(data) {   },   error:function(err) {   }   });

Method Two:

Package Form label required (for large data volumes, element set)

functionAddhandlingfeetorefund () {varAjaxurl= ". /ordermanagement/ajaxmodifyorderservice.aspx "; Alert ($ (' #formAddHandlingFee '). Serialize ()); $.ajax ({type:"POST", DataType:"HTML", Url:ajaxurl+ '? action= ' + ' submithandlingfee ' + ' &ordernumber= ' + $.trim ($ ("#<%=this.txtordernumber.clientid%>"). Val ()), Data: $ (' #formAddHandlingFee '). Serialize (), Success:function(Result) {varstrresult=result;                        alert (strresult); //load maximum refundable amount$ ("#spanMaxAmount"). HTML (strresult); }, Error:function(data) {alert ("Error:" +data.responsetext);        }                }); }

HTML code:

<formID= "Formaddhandlingfee"name= "Formaddhandlingfee"enctype= "Multipart/form-data"onsubmit= "Addhandlingfeetorefund ()">                    <TableID= "Addhandlingfee"class= "Wfill">                        <TR>                            <TD>                                <asp:literalID= "Ui_amount"runat= "Server"Text= "Processing fee"Meta:resourcekey= "Handlingfeeamount" />                            </TD>                            <TD>                                <inputtype= "text"ID= "Txthandlingfeeamount"name= "Txthandlingfeeamount"class= "{required:true,number:true}"maxlength= " a" />                            </TD>                        </TR>                        <TR>                            <TD>                                <asp:literalID= "Ui_handlingfeetype"runat= "Server"Text= "Fee Type"Meta:resourcekey= "Handlingfeehandlingfeetype" />                            </TD>                            <TD>                                <Crmweb:htmlselectcontrolID= "Handlingfeetype"Enumtypename= "Dx.oms.model.common.handlingfeetype,dx.oms.model.common"Emptyvalue=""Emptytext= "Select"runat= "Server"class= "Text {required:true}"/>                            </TD>                        </TR>                        <TR>                            <TD>                                <asp:literalID= "Ui_notes"runat= "Server"Text= "Remarks"Meta:resourcekey= "Handlingfeenotes" />                            </TD>                            <TD>                                <textareaID= "Txtnotes"name= "Txtnotes"class= "Text {required:true}"cols= "All"rows= "2"maxlength= "+"></textarea>                            </TD>                        </TR>                        <TR>                            <TD>                            </TD>                            <TD>                                <inputID= "Submit1"type= "Submit"value= "Add processing fee"  />                                <Asp:buttonID= "Button1"runat= "Server"Text= "Add processing fee"OnClientClick= "Javascript:addhandlingfeetorefund ()" />                            </TD>                        </TR>                    </Table>                    </form>

A summary of how jquery implements AJAX submission forms

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.