jquery的ajax提交form表單的兩種方法小結(推薦)_jquery

來源:互聯網
上載者:User

jquery的ajax提交form表單的兩種方法小結(推薦)

方法一:

function AddHandlingFeeToRefund()    {      var AjaxURL= "../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) {            var strresult=result;            alert(strresult);            //載入最大可退金額            $("#spanMaxAmount").html(strresult);          },          error: function(data) {            alert("error:"+data.responseText);           }        });    }

方法二:

    //ajax提交form表單的方式    $('#formAddHandlingFee').submit(function() {      var AjaxURL= "../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 (data) {            var strresult=data;            alert(strresult);            //載入最大可退金額            $("#spanMaxAmount").html(strresult);          },          error: function(data) {            alert("error:"+data.responseText);           }        });    }  );

頁面html代碼:

<form id="formAddHandlingFee" name="formAddHandlingFee" enctype="multipart/form-data" onsubmit="AddHandlingFeeToRefund()"> <table id="AddHandlingFee" class="Wfill">   <tr>     <td>       <asp:Literal ID="UI_Amount" runat="server" Text="處理費用" meta:resourcekey="HandlingFeeAmount" />     </td>     <td>       <input type="text" id="txtHandlingFeeAmount" name="txtHandlingFeeAmount" class="{required:true,number:true}" maxlength="12" />     </td>   </tr>   <tr>     <td>       <asp:Literal ID="UI_HandlingFeeType" runat="server" Text="費用類型" meta:resourcekey="HandlingFeeHandlingFeeType" />     </td>     <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>   <tr>     <td>       <asp:Literal ID="UI_Notes" runat="server" Text="備忘" meta:resourcekey="HandlingFeeNotes" />     </td>     <td>       <textarea id="txtNotes" name="txtNotes" class="text {required:true}" cols="22" rows="2" maxlength="100"></textarea>     </td>   </tr>      <tr>     <td>     </td>     <td>       <input id="Submit1" type="submit" value="添加處理費" />       <asp:Button ID="Button1" runat="server" Text="添加處理費" OnClientClick="javascript:AddHandlingFeeToRefund()" />     </td>        </tr> </table> </form>

以上這篇jquery的ajax提交form表單的兩種方法小結(推薦)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援雲棲社區。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.