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>

                            主站蜘蛛池模板: 武汉高温老化房,恒温恒湿试验箱,冷热冲击试验箱-武汉安德信检测设备有限公司 | POM塑料_PBT材料「进口」聚甲醛POM杜邦原料、加纤PBT塑料报价格找利隆塑料 | 西安文都考研官网_西安考研辅导班_考研培训机构_西安在职考研培训 | 耐高温电缆厂家-远洋高温电缆 | 1000帧高速摄像机|工业高速相机厂家|科天健光电技术 | 天津电机维修|水泵维修-天津晟佳机电设备有限公司 | 镀锌角钢_槽钢_扁钢_圆钢_方矩管厂家_镀锌花纹板-海邦钢铁(天津)有限公司 | 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 微妙网,专业的动画师、特效师、CG模型设计师网站! - wmiao.com 超声波电磁流量计-液位计-孔板流量计-料位计-江苏信仪自动化仪表有限公司 | 涡轮流量计_LWGY智能气体液体电池供电计量表-金湖凯铭仪表有限公司 | 螺旋丝杆升降机-SWL蜗轮-滚珠丝杆升降机厂家-山东明泰传动机械有限公司 | 北京银联移动POS机办理_收银POS机_智能pos机_刷卡机_收银系统_个人POS机-谷骐科技【官网】 | 报警器_家用防盗报警器_烟雾报警器_燃气报警器_防盗报警系统厂家-深圳市刻锐智能科技有限公司 | 骨龄仪_骨龄检测仪_儿童骨龄测试仪_品牌生产厂家【品源医疗】 | 带锯机|木工带锯机圆木推台锯|跑车带锯机|河北茂业机械制造有限公司| | 柔软云母板-硬质-水位计云母片组件-首页-武汉长丰云母绝缘材料有限公司 | 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 企业微信scrm管理系统_客户关系管理平台_私域流量运营工具_CRM、ERP、OA软件-腾辉网络 | 云阳人才网_云阳招聘网_云阳人才市场_云阳人事人才网_云阳人家招聘网_云阳最新招聘信息 | 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 碎石机设备-欧版反击破-欧版颚式破碎机(站)厂家_山东奥凯诺机械 高低温试验箱-模拟高低温试验箱订制-北京普桑达仪器科技有限公司【官网】 | 爆破器材运输车|烟花爆竹运输车|1-9类危险品厢式运输车|湖北江南专用特种汽车有限公司 | 风化石头制砂机_方解石制砂机_瓷砖石子制砂机_华盛铭厂家 | 曙光腾达官网-天津脚手架租赁-木板架出租-移动门式脚手架租赁「免费搭设」 | 防潮防水通风密闭门源头实力厂家 - 北京酷思帝克门窗 | 无刷电机_直流无刷电机_行星减速机-佛山市藤尺机电设备有限公司 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 美侍宠物-专注宠物狗及宠物猫训练|喂养|医疗|繁育|品种|价格 | 环氧铁红防锈漆_环氧漆_无溶剂环氧涂料_环氧防腐漆-华川涂料 | 软装设计-提供软装装饰和软装配饰及软装陈设的软装设计公司 | 航空连接器,航空插头,航空插座,航空接插件,航插_深圳鸿万科 | 长江船运_国内海运_内贸船运_大件海运|运输_船舶运输价格_钢材船运_内河运输_风电甲板船_游艇运输_航运货代电话_上海交航船运 | 黄石东方妇产医院_黄石妇科医院哪家好_黄石无痛人流医院 | 上海三信|ph计|酸度计|电导率仪-艾科仪器 | 捆扎机_气动捆扎机_钢带捆扎机-沈阳海鹞气动钢带捆扎机公司 | 天津暖气片厂家_钢制散热器_天津铜铝复合暖气片_维尼罗散热器 | 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格 | MES系统-WMS系统-MES定制开发-制造执行MES解决方案-罗浮云计算 | 福建省教师资格证-福建教师资格证考试网| TMT观察网_独特视角观察TMT行业 派财经_聚焦数字经济内容服务平台 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 |