pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      • <bdo id='7SRNv'></bdo><ul id='7SRNv'></ul>

        <tfoot id='7SRNv'></tfoot>
      1. <i id='7SRNv'><tr id='7SRNv'><dt id='7SRNv'><q id='7SRNv'><span id='7SRNv'><b id='7SRNv'><form id='7SRNv'><ins id='7SRNv'></ins><ul id='7SRNv'></ul><sub id='7SRNv'></sub></form><legend id='7SRNv'></legend><bdo id='7SRNv'><pre id='7SRNv'><center id='7SRNv'></center></pre></bdo></b><th id='7SRNv'></th></span></q></dt></tr></i><div class="ak2yqoa" id='7SRNv'><tfoot id='7SRNv'></tfoot><dl id='7SRNv'><fieldset id='7SRNv'></fieldset></dl></div>
      2. <legend id='7SRNv'><style id='7SRNv'><dir id='7SRNv'><q id='7SRNv'></q></dir></style></legend>

        <small id='7SRNv'></small><noframes id='7SRNv'>

        使用內(nèi)置功能在 MVC6 中使用 JQuery AJAX 提交剃刀表

        Submitting a razor form using JQuery AJAX in MVC6 using the built-in functionality(使用內(nèi)置功能在 MVC6 中使用 JQuery AJAX 提交剃刀表單)

      3. <legend id='S5fnJ'><style id='S5fnJ'><dir id='S5fnJ'><q id='S5fnJ'></q></dir></style></legend>
          <bdo id='S5fnJ'></bdo><ul id='S5fnJ'></ul>

            <small id='S5fnJ'></small><noframes id='S5fnJ'>

                <tbody id='S5fnJ'></tbody>
                <tfoot id='S5fnJ'></tfoot>
              • <i id='S5fnJ'><tr id='S5fnJ'><dt id='S5fnJ'><q id='S5fnJ'><span id='S5fnJ'><b id='S5fnJ'><form id='S5fnJ'><ins id='S5fnJ'></ins><ul id='S5fnJ'></ul><sub id='S5fnJ'></sub></form><legend id='S5fnJ'></legend><bdo id='S5fnJ'><pre id='S5fnJ'><center id='S5fnJ'></center></pre></bdo></b><th id='S5fnJ'></th></span></q></dt></tr></i><div class="i0s2iuo" id='S5fnJ'><tfoot id='S5fnJ'></tfoot><dl id='S5fnJ'><fieldset id='S5fnJ'></fieldset></dl></div>

                  本文介紹了使用內(nèi)置功能在 MVC6 中使用 JQuery AJAX 提交剃刀表單的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我想知道在 MVC6 中是否有使用 jQuery AJAX 提交表單的特定方法,仍然使用 ASP.NET MVC 的自動綁定功能.我相信在其他版本的 MVC 中,您可以使用 jquery.unobtrusive-ajax 并簡單地使用

                  I would like to know if there is a specific way to submit a form using jQuery AJAX in MVC6, still using the Auto Binding features of ASP.NET MVC. I believe in other versions of MVC you could use jquery.unobtrusive-ajax and simply use

                  @using (Ajax.BeginForm("SaveData", new AjaxOptions(){}
                  

                  由于 MVC6 發(fā)生了一些變化,我想知道除了在提交表單時向服務(wù)器執(zhí)行正常的 AJAX 發(fā)布之外,新推薦的方法是什么.這意味著我將手動獲取每個輸入字段的值,將它們轉(zhuǎn)換為 JSON 并將它們發(fā)送到控制器,以便所有內(nèi)容都綁定到 ViewModel.

                  Since there have been some changes with MVC6 I am wondering what the new recommended way to do this would be besides doing a normal AJAX post to the server when the form is submitted. This meaning I would manually get the values of each input field, turn them into JSON and send them over to the controller so everything will get bound to the ViewModel.

                  如果我將以下 JavaScript 用于 AJAX,那么任何 AJAX 表單設(shè)置是否重要?

                  If I use the following JavaScript for AJAX do any of the AJAX form settings even matter?

                  $('form').submit(function () {
                      $.ajax({
                          type: "POST",
                          url: "/Products/Create/",
                          data: JSON.stringify(data),
                          contentType: "application/json; charset=utf-8",
                          dataType: "json"
                      });
                  });
                  

                  推薦答案

                  Ajax 的工作方式相同,但使用新的 MVC 6 Tag Helper 代替 @Ajax 幫助器(不要忘記引用 'jquery' 和 'jquery.unobtrusive-ajax 腳本).

                  Ajax works the same way, but instead of the @Ajax helper's, use the new MVC 6 Tag Helpers (don't forget to reference 'jquery' and 'jquery.unobtrusive-ajax' scripts).

                  JQuery Unobtrusive Ajax 存在于 Asp.Net GitHub repo 中,可以被 Bower 拉取.

                  JQuery Unobtrusive Ajax exists in the Asp.Net GitHub repo and can be Bower pulled.

                  使用新的 MVC TagHelpers,您只需聲明如下形式:

                  Using the new MVC TagHelpers, you simply declare the form like the following:

                  <form asp-controller="Home" asp-action="SaveForm" data-ajax="true" data-ajax-method="POST">
                  ...
                  </form>
                  

                  要使用以前 MVC 版本的 Ajax Helper 上存在的 AjaxOptions,只需添加這些屬性,執(zhí)行 form 標記,如下所示:

                  To use the AjaxOptions that existed on the Ajax Helper on previous MVC versions, just add those attributes do the form tag like this:

                  <form asp-controller="Home" asp-action="SaveForm" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#content">
                  ...
                  </form>
                  <div id="content"></div>
                  

                  您可以在表單中使用的 HTML 屬性(以前稱為 AjaxOptions)如下(原文出處):

                  The HTML attributes (formerly AjaxOptions) that you can use in the form are the following (original source):

                  +------------------------+-----------------------------+
                  |      AjaxOptions       |       HTML attribute        |
                  +------------------------+-----------------------------+
                  | Confirm                | data-ajax-confirm           |
                  | HttpMethod             | data-ajax-method            |
                  | InsertionMode          | data-ajax-mode              |
                  | LoadingElementDuration | data-ajax-loading-duration  |
                  | LoadingElementId       | data-ajax-loading           |
                  | OnBegin                | data-ajax-begin             |
                  | OnComplete             | data-ajax-complete          |
                  | OnFailure              | data-ajax-failure           |
                  | OnSuccess              | data-ajax-success           |
                  | UpdateTargetId         | data-ajax-update            |
                  | Url                    | data-ajax-url               |
                  +------------------------+-----------------------------+
                  

                  另一個重大變化是如何在服務(wù)器端檢查請求是否確實是 AJAX 請求.在以前的版本中,我們只是使用 Request.IsAjaxRequest().

                  Another significant change is how you check on the server side if the request is indeed an AJAX request. On previous versions we simply used Request.IsAjaxRequest().

                  在 MVC6 上,您必須創(chuàng)建一個簡單的擴展來添加與以前的 MVC 版本相同的選項(原文出處):

                  On MVC6, you have to create a simple extension to add the same options that existed on previous MVC versions (original source):

                  /// <summary>
                  /// Determines whether the specified HTTP request is an AJAX request.
                  /// </summary>
                  /// 
                  /// <returns>
                  /// true if the specified HTTP request is an AJAX request; otherwise, false.
                  /// </returns>
                  /// <param name="request">The HTTP request.</param><exception cref="T:System.ArgumentNullException">The <paramref name="request"/> parameter is null (Nothing in Visual Basic).</exception>
                  public static bool IsAjaxRequest(this HttpRequest request)
                  {
                    if (request == null)
                      throw new ArgumentNullException("request");
                  
                    if (request.Headers != null)
                      return request.Headers["X-Requested-With"] == "XMLHttpRequest";
                    return false;
                  }
                  

                  這篇關(guān)于使用內(nèi)置功能在 MVC6 中使用 JQuery AJAX 提交剃刀表單的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)

                    <small id='Ul4JN'></small><noframes id='Ul4JN'>

                          <tbody id='Ul4JN'></tbody>
                        <legend id='Ul4JN'><style id='Ul4JN'><dir id='Ul4JN'><q id='Ul4JN'></q></dir></style></legend>

                          <bdo id='Ul4JN'></bdo><ul id='Ul4JN'></ul>

                            <tfoot id='Ul4JN'></tfoot>
                            <i id='Ul4JN'><tr id='Ul4JN'><dt id='Ul4JN'><q id='Ul4JN'><span id='Ul4JN'><b id='Ul4JN'><form id='Ul4JN'><ins id='Ul4JN'></ins><ul id='Ul4JN'></ul><sub id='Ul4JN'></sub></form><legend id='Ul4JN'></legend><bdo id='Ul4JN'><pre id='Ul4JN'><center id='Ul4JN'></center></pre></bdo></b><th id='Ul4JN'></th></span></q></dt></tr></i><div class="2c2yo2e" id='Ul4JN'><tfoot id='Ul4JN'></tfoot><dl id='Ul4JN'><fieldset id='Ul4JN'></fieldset></dl></div>

                            主站蜘蛛池模板: 商标转让-商标注册-商标查询-软著专利服务平台 - 赣江万网 | 钢化玻璃膜|手机钢化膜|钢化膜厂家|手机保护膜-【东莞市大象电子科技有限公司】 | 北京三友信电子科技有限公司-ETC高速自动栏杆机|ETC机柜|激光车辆轮廓测量仪|嵌入式车道控制器 | 万濠影像仪(万濠投影仪)百科-苏州林泽仪器 | 废气处理设备-工业除尘器-RTO-RCO-蓄热式焚烧炉厂家-江苏天达环保设备有限公司 | SF6环境监测系统-接地环流在线监测装置-瑟恩实业 | 闪蒸干燥机-喷雾干燥机-带式干燥机-桨叶干燥机-[常州佳一干燥设备] | 集装袋吨袋生产厂家-噸袋廠傢-塑料编织袋-纸塑复合袋-二手吨袋-太空袋-曹县建烨包装 | 香港新时代国际美容美发化妆美甲培训学校-26年培训经验,值得信赖! | 首页|专注深圳注册公司,代理记账报税,注册商标代理,工商变更,企业400电话等企业一站式服务-慧用心 | ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 防腐木批发价格_深圳_惠州_东莞防腐木厂家_森源(深圳)防腐木有限公司 | 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | RS系列电阻器,RK_RJ启动调整电阻器,RQ_RZ电阻器-上海永上电器有限公司 | 桨叶搅拌机_螺旋挤压/方盒旋切造粒机厂家-无锡市鸿诚输送机械有限公司 | 微水泥_硅藻泥_艺术涂料_艺术漆_艺术漆加盟-青岛泥之韵环保壁材 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 干培两用箱-细菌恒温培养箱-菲斯福仪器 | 拖鞋定制厂家-品牌拖鞋代加工厂-振扬实业中国高端拖鞋大型制造商 | 东莞市踏板石餐饮管理有限公司_正宗桂林米粉_正宗桂林米粉加盟_桂林米粉加盟费-东莞市棒子桂林米粉 | 电解抛光加工_不锈钢电解抛光_常州安谱金属制品有限公司 | 千斤顶,液压千斤顶-力良企业,专业的液压千斤顶制造商,shliliang.com | 100国际学校招生 - 专业国际学校择校升学规划| 英超直播_英超免费在线高清直播_英超视频在线观看无插件-24直播网 | 板框压滤机-隔膜压滤机配件生产厂家-陕西华星佳洋装备制造有限公司 | 脉冲布袋除尘器_除尘布袋-泊头市净化除尘设备生产厂家 | 铁素体测量仪/检测仪/铁素体含量测试仪-苏州圣光仪器有限公司 | 东莞画册设计_logo/vi设计_品牌包装设计 - 华略品牌设计公司 | 澳威全屋定制官网|极简衣柜十大品牌|衣柜加盟代理|全屋定制招商 百度爱采购运营研究社社群-店铺托管-爱采购代运营-良言多米网络公司 | 商秀—企业短视频代运营_抖音企业号托管 | 宝鸡市人民医院| 西门子伺服电机维修,西门子电源模块维修,西门子驱动模块维修-上海渠利 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | ptc_浴霸_大巴_干衣机_呼吸机_毛巾架_电动车加热器-上海帕克 | 车件|铜件|车削件|车床加工|五金冲压件-PIN针,精密车件定制专业厂商【东莞品晔】 | 信阳市建筑勘察设计研究院有限公司 | 周口市风机厂,周鼓风机,河南省周口市风机厂 | 扒渣机厂家_扒渣机价格_矿用扒渣机_铣挖机_撬毛台车_襄阳永力通扒渣机公司 | 无线遥控更衣吊篮_IC卡更衣吊篮_电动更衣吊篮配件_煤矿更衣吊篮-力得电子 | 400电话_400电话申请_866元/年_【400电话官方业务办理】-俏号网 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | 模型公司_模型制作_沙盘模型报价-中国模型网 | 净化板-洁净板-净化板价格-净化板生产厂家-山东鸿星新材料科技股份有限公司 |