久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <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="qwawimqqmiuu" 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'>

        使用內置功能在 MVC6 中使用 JQuery AJAX 提交剃刀表

        Submitting a razor form using JQuery AJAX in MVC6 using the built-in functionality(使用內置功能在 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="qwawimqqmiuu" id='S5fnJ'><tfoot id='S5fnJ'></tfoot><dl id='S5fnJ'><fieldset id='S5fnJ'></fieldset></dl></div>

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

                  問題描述

                  我想知道在 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 發生了一些變化,我想知道除了在提交表單時向服務器執行正常的 AJAX 發布之外,新推薦的方法是什么.這意味著我將手動獲取每個輸入字段的值,將它們轉換為 JSON 并將它們發送到控制器,以便所有內容都綁定到 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 表單設置是否重要?

                  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,只需添加這些屬性,執行 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               |
                  +------------------------+-----------------------------+
                  

                  另一個重大變化是如何在服務器端檢查請求是否確實是 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 上,您必須創建一個簡單的擴展來添加與以前的 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;
                  }
                  

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

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

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發點擊傳單標記)
                  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 圖層控件添加到側邊欄)

                    <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="qwawimqqmiuu" id='Ul4JN'><tfoot id='Ul4JN'></tfoot><dl id='Ul4JN'><fieldset id='Ul4JN'></fieldset></dl></div>

                            主站蜘蛛池模板: 夜久久 | 精品在线免费看 | 久热精品在线播放 | 欧美激情在线精品一区二区三区 | 羞羞视频在线观看免费观看 | 色婷综合网| 美女131mm久久爽爽免费 | 国产精彩视频 | 欧美精品久久久久久久久老牛影院 | 国产精品久久久久久一区二区三区 | 欧美综合久久 | 一本大道久久a久久精二百 国产成人免费在线 | 国产专区在线 | 亚洲 欧美 在线 一区 | 日韩亚洲一区二区 | 亚洲第一中文字幕 | 国产精品区二区三区日本 | 免费一区在线 | 久久精品国产一区二区三区不卡 | 欧美极品视频在线观看 | 在线看一区二区 | 日本字幕在线观看 | 亚洲国产欧美在线 | 亚洲欧美日韩电影 | 日韩在线视频一区 | 黄色网毛片 | 欧美精品二区三区 | 亚洲在线一区 | 久久这里只有精品首页 | 可以免费观看的av片 | 国产精品久久久久不卡 | 日韩av在线中文字幕 | 在线观看免费福利 | 亚洲精品电影网在线观看 | 在线免费观看黄色 | 国产精品69久久久久水密桃 | 一级在线毛片 | 国产成都精品91一区二区三 | 欧美在线视频一区 | 免费看黄色小视频 | 日韩欧美国产精品一区二区三区 |