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>

                            主站蜘蛛池模板: 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 脱硝喷枪-氨水喷枪-尿素喷枪-河北思凯淋环保科技有限公司 | AGV叉车|无人叉车|AGV智能叉车|AGV搬运车-江西丹巴赫机器人股份有限公司 | 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 济南冷库安装-山东冷库设计|建造|冷库维修-山东齐雪制冷设备有限公司 | 车件|铜件|车削件|车床加工|五金冲压件-PIN针,精密车件定制专业厂商【东莞品晔】 | Trimos测长机_测高仪_TESA_mahr,WYLER水平仪,PWB对刀仪-德瑞华测量技术(苏州)有限公司 | 恒温槽_恒温水槽_恒温水浴槽-上海方瑞仪器有限公司 | 彼得逊采泥器-定深式采泥器-电动土壤采样器-土壤样品风干机-常州索奥仪器制造有限公司 | 不锈钢螺丝,不锈钢螺栓,不锈钢标准件-江苏百德特种合金有限公司 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 电动高压冲洗车_价格-江苏速利达机车有限公司 | 无锡市珂妮日用化妆品有限公司|珂妮日化官网|洗手液厂家 | 氧化锆陶瓷_氧化锆陶瓷加工_氧化锆陶瓷生产厂家-康柏工业陶瓷有限公司 | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 股票入门基础知识_股票知识_股票投资大师_格雷厄姆网 | TPM咨询,精益生产管理,5S,6S现场管理培训_华谋咨询公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 包头市鑫枫装饰有限公司| 传爱自考网_传爱自学考试网| 退火炉,燃气退火炉,燃气热处理炉生产厂家-丹阳市丰泰工业炉有限公司 | 纸布|钩编布|钩针布|纸草布-莱州佳源工艺纸布厂 | 防爆电机_防爆电机型号_河南省南洋防爆电机有限公司 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 贴片电容-贴片电阻-二三极管-国巨|三星|风华贴片电容代理商-深圳伟哲电子 | 冷却塔降噪隔音_冷却塔噪声治理_冷却塔噪音处理厂家-广东康明冷却塔降噪厂家 | 扬子叉车厂家_升降平台_电动搬运车|堆高车-扬子仓储叉车官网 | 充气膜专家-气膜馆-PTFE膜结构-ETFE膜结构-商业街膜结构-奥克金鼎 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 北京网站建设首页,做网站选【优站网】,专注北京网站建设,北京网站推广,天津网站建设,天津网站推广,小程序,手机APP的开发。 | 安全光栅|射频导纳物位开关|音叉料位计|雷达液位计|两级跑偏开关|双向拉绳开关-山东卓信机械有限公司 | 锥形螺带干燥机(新型耙式干燥机)百科-常州丰能干燥工程 | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 电动葫芦|防爆钢丝绳电动葫芦|手拉葫芦-保定大力起重葫芦有限公司 | 紧急切断阀_气动切断阀_不锈钢阀门_截止阀_球阀_蝶阀_闸阀-上海上兆阀门制造有限公司 | 变压器配件,变压器吸湿器,武强县吉口变压器配件有限公司 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 广州网站建设_小程序开发_番禺网站建设_佛山网站建设_粤联网络 | 冷轧机|两肋冷轧机|扁钢冷轧机|倒立式拉丝机|钢筋拔丝机|收线机-巩义市华瑞重工机械制造有限公司 | 焊缝跟踪系统_激光位移传感器_激光焊缝跟踪传感器-创想智控 | 宁波普瑞思邻苯二甲酸盐检测仪,ROHS2.0检测设备,ROHS2.0测试仪厂家 |