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

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

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

  • <legend id='LqnOz'><style id='LqnOz'><dir id='LqnOz'><q id='LqnOz'></q></dir></style></legend>

          <bdo id='LqnOz'></bdo><ul id='LqnOz'></ul>
      1. <tfoot id='LqnOz'></tfoot>

        FormData() 對象不會從表單添加提交類型的輸入,而

        FormData() object does not add submit-type inputs from form, while on Firefox(FormData() 對象不會從表單添加提交類型的輸入,而在 Firefox 上)
          <tbody id='DgiYK'></tbody>
        <i id='DgiYK'><tr id='DgiYK'><dt id='DgiYK'><q id='DgiYK'><span id='DgiYK'><b id='DgiYK'><form id='DgiYK'><ins id='DgiYK'></ins><ul id='DgiYK'></ul><sub id='DgiYK'></sub></form><legend id='DgiYK'></legend><bdo id='DgiYK'><pre id='DgiYK'><center id='DgiYK'></center></pre></bdo></b><th id='DgiYK'></th></span></q></dt></tr></i><div class="5lh5t5z" id='DgiYK'><tfoot id='DgiYK'></tfoot><dl id='DgiYK'><fieldset id='DgiYK'></fieldset></dl></div>
        <legend id='DgiYK'><style id='DgiYK'><dir id='DgiYK'><q id='DgiYK'></q></dir></style></legend>
            • <bdo id='DgiYK'></bdo><ul id='DgiYK'></ul>

              <tfoot id='DgiYK'></tfoot>
              1. <small id='DgiYK'></small><noframes id='DgiYK'>

                  本文介紹了FormData() 對象不會從表單添加提交類型的輸入,而在 Firefox 上的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  今天我遇到了一個有趣的錯誤,花了很多時間才弄清楚.

                  設置

                  頁面上的表單.提交時,數據被捕獲并用它創建 new FormData() 對象.

                  該對象通過 xhr 請求發送到 .php 腳本,然后返回 ok/error 消息.

                  代碼看起來像這樣:(簡化版,不需要絨毛)

                  將其發送到 .php 將產生一個如下所示的數組:

                  數組([名稱] =>一些名字[電子郵件] =>一些電子郵件[電話] =>11111111[網站] =>一些網站[詳情] =>一些細節[發送] =>發送)

                  .php 將響應 {"message":"ok","code":0}{"message":"error","代碼":1}

                  現在這是預期的行為.這是我在 Chrome、IE 或 Safari 上得到的.

                  問題

                  然而,在 Firefox 上,除了沒有 submit 輸入 (name="send") 鍵/值對之外,我得到相同的數組:

                  數組([名稱] =>一些名字[電子郵件] =>一些電子郵件[電話] =>11111111[網站] =>一些網站[詳情] =>一些細節)

                  我在 Linux 和 Windows 上都嘗試過,以覆蓋我的基礎,但它仍然給出了同樣不令人滿意的結果.

                  解決方案

                  在網上搜索并出現空白后,我解決它的方法(更多的補丁,而不是真正解決)是覆蓋 send 鍵/值:

                  var data = new FormData(frm);data.append('發送', '發送');xhr.send(數據);

                  這是可行的,因為如果它已經定義(Chrome 等......)它會被覆蓋,如果它不存在,它就會被創建.

                  問題

                  1. 類似情況 - 您是否遇到過類似情況?
                  2. 修復 - 我認為我的解決方案是 hack,您有什么更好的修復方法嗎?

                  解決方案

                  根據 WHATWG 規范,FireFox 似乎是正確的.

                  FormDataXMLHttpRequest 規范> 構造函數說:

                  <塊引用>

                  1. 如果給出 form,則將 fd 的條目設置為 構造form 的表單數據集.

                  那么在構造表單數據集的描述中,是這樣說的:

                  <塊引用>

                  在提交者提交者的上下文中form可選地構造表單數據集的算法如下.如果沒有另外指定,提交者為空.

                  表單中的按鈕只有在提交者的情況下才會包含在表單數據集中.但是當這個算法從 FormData 構造函數中執行時,沒有指定提交者,所以表單數據集中不應該包含任何按鈕.

                  Today I came across an interesting bug, which took a good chunk of time to get to the bottom of.

                  The setup

                  A form on a page. On submit, the data gets captured and new FormData() object gets created with it.

                  That object gets sent with and xhr request to an .php script, which then returns an ok / error message.

                  The code looks something like this: (simplified version, no need for fluff)

                  <form name="frm" id="frm" action="" method="post" onsubmit="save(event, this);" enctype="multipart/form-data">
                      <input name="name" id="name" type="text" value="..." />
                      <input name="email" id="email" type="text" value="..." />
                      <input name="phone" id="phone" type="text" value="..." />
                      <input name="website" id="website" type="text" value="..." />
                      <textarea name="details" id="details"></textarea>
                      <input name="send" type="submit" value="Send" />
                  </form>
                  
                  <script type="text/javascript">
                  
                  function save(e, frm) {
                  
                          if (document.getElementById('nume').value == '' ||
                            document.getElementById('email').value == '' ||
                            document.getElementById('telefon').value == '' ||
                            document.getElementById('site').value == '') {
                  
                              alert('Forms empty');
                  
                          } else {
                  
                              var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
                  
                              xhr.onreadystatechange = function () {
                                  if (xhr.readyState == 4) {
                  
                                      var r = JSON.parse(xhr.responseText);
                  
                                      if (r.code == 0) {
                                          document.getElementById('message_ok').style.display = 'block';
                                      } else {
                                          document.getElementById('message_err').style.display = 'block';
                                      }
                                  }
                              };
                  
                              xhr.open('POST', 'http://url', true);
                              var data = new FormData(frm);
                              xhr.send(data);
                  
                          }
                      e.preventDefault();
                  }
                  
                  </script>
                  

                  Sending this to .php will result in an array which kind of looks like this:

                  Array
                  (
                      [name] => some name
                      [email] => some email
                      [phone] => 11111111
                      [website] => some site
                      [details] => some details
                      [send] => Send
                  )
                  

                  and .php will respond with either {"message":"ok","code":0} or {"message":"error","code":1}

                  Now this is the expected behavior. This is what I get on either Chrome, IE or Safari.

                  The problem

                  On Firefox however, I get the same array except without the submit input (name="send") key/value pair:

                  Array
                  (
                      [name] => some name
                      [email] => some email
                      [phone] => 11111111
                      [website] => some site
                      [details] => some details
                  )
                  

                  I tried on both Linux and Windows, to cover my basis, yet it still gave the same unsatisfying result.

                  Solution

                  After searching online and coming up empty, the way I solved it (more of patching, not really solving) was to overwrite the send key/value:

                  var data = new FormData(frm);
                  data.append('send', 'Send');
                  xhr.send(data);
                  

                  This works, because if it's already defined (Chrome, etc...) it gets overwritten, if it doesn't exist, it gets created.

                  Questions

                  1. Similar - Have you ever faced something similar?
                  2. Fix - I consider my solution a hack, have you got any ideas for a better fix?

                  解決方案

                  FireFox seems to be correct, according to the WHATWG specification.

                  The XMLHttpRequest specification of the FormData constructor says:

                  1. If form is given, set fd's entries to the result of constructing the form data set for form.

                  Then in the description of constructing the form data set, it says:

                  The algorithm to construct the form data set for a form form optionally in the context of a submitter submitter is as follows. If not specified otherwise, submitter is null.

                  A button in the form is only included in the form data set if it's the submitter. But when this algorithm is executed from the FormData constructor, no submitter is specified, so no buttons should be included in the form data set.

                  這篇關于FormData() 對象不會從表單添加提交類型的輸入,而在 Firefox 上的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                1. <tfoot id='YH9Ep'></tfoot>
                  <i id='YH9Ep'><tr id='YH9Ep'><dt id='YH9Ep'><q id='YH9Ep'><span id='YH9Ep'><b id='YH9Ep'><form id='YH9Ep'><ins id='YH9Ep'></ins><ul id='YH9Ep'></ul><sub id='YH9Ep'></sub></form><legend id='YH9Ep'></legend><bdo id='YH9Ep'><pre id='YH9Ep'><center id='YH9Ep'></center></pre></bdo></b><th id='YH9Ep'></th></span></q></dt></tr></i><div class="5hbz7lx" id='YH9Ep'><tfoot id='YH9Ep'></tfoot><dl id='YH9Ep'><fieldset id='YH9Ep'></fieldset></dl></div>
                      <bdo id='YH9Ep'></bdo><ul id='YH9Ep'></ul>

                          <tbody id='YH9Ep'></tbody>

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

                        • <legend id='YH9Ep'><style id='YH9Ep'><dir id='YH9Ep'><q id='YH9Ep'></q></dir></style></legend>
                            主站蜘蛛池模板: 杰恒蠕动泵-蠕动泵专业厂家-19年专注蠕动泵 | 篮球架_乒乓球台_足球门_校园_竞技体育器材_厂家_价格-沧州浩然体育器材有限公司 | 软文世界-软文推广-软文营销-新闻稿发布-一站式软文自助发稿平台 | 恒温恒湿试验箱厂家-高低温试验箱维修价格_东莞环仪仪器_东莞环仪仪器 | 制冷采购电子商务平台——制冷大市场 | 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 排烟防火阀-消防排烟风机-正压送风口-厂家-价格-哪家好-德州鑫港旺通风设备有限公司 | 南京租车,南京汽车租赁,南京包车,南京会议租车-南京七熹租车 | 服务器之家 - 专注于服务器技术及软件下载分享 | Jaeaiot捷易科技-英伟达AI显卡模组/GPU整机服务器供应商 | 广州活动策划公司-15+年专业大型公关活动策划执行管理经验-睿阳广告 | 福建成考网-福建成人高考网| 爱科技iMobile-专业的科技资讯信息分享网站 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | 工业制氮机_psa制氮机厂家-宏骁智能装备科技江苏有限公司 | 焊锡丝|焊锡条|无铅锡条|无铅锡丝|无铅焊锡线|低温锡膏-深圳市川崎锡业科技有限公司 | 超声波反应釜【百科】-以马内利仪器 | 带式压滤机_污泥压滤机_污泥脱水机_带式过滤机_带式压滤机厂家-河南恒磊环保设备有限公司 | 塑料检查井_双扣聚氯乙烯增强管_双壁波纹管-河南中盈塑料制品有限公司 | 杭州代理记账费用-公司注销需要多久-公司变更监事_杭州福道财务管理咨询有限公司 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 珠海网站建设_响应网站建设_珠海建站公司_珠海网站设计与制作_珠海网讯互联 | 日本SMC气缸接头-速度控制阀-日本三菱伺服电机-苏州禾力自动化科技有限公司 | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 酒精检测棒,数显温湿度计,酒安酒精测试仪,酒精检测仪,呼气式酒精检测仪-郑州欧诺仪器有限公司 | 电子万能试验机_液压拉力试验机_冲击疲劳试验机_材料试验机厂家-济南众标仪器设备有限公司 | arch电源_SINPRO_开关电源_模块电源_医疗电源-东佑源 | 办公室家具_板式办公家具定制厂家-FMARTS福玛仕办公家具 | 连续密炼机_双转子连续密炼机_连续式密炼机-南京永睿机械制造有限公司 | 商标转让-购买商标专业|放心的商标交易网-蜀易标商标网 | 镀锌方管,无缝方管,伸缩套管,方矩管_山东重鑫致胜金属制品有限公司 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 武汉天安盾电子设备有限公司 - 安盾安检,武汉安检门,武汉安检机,武汉金属探测器,武汉测温安检门,武汉X光行李安检机,武汉防爆罐,武汉车底安全检查,武汉液体探测仪,武汉安检防爆设备 | UV固化机_UVLED光固化机_UV干燥机生产厂家-上海冠顶公司专业生产UV固化机设备 | 透平油真空滤油机-变压器油板框滤油机-滤油车-华之源过滤设备 | 气力输送设备_料封泵_仓泵_散装机_气化板_压力释放阀-河南锐驰机械设备有限公司 | 即用型透析袋,透析袋夹子,药敏纸片,L型涂布棒-上海桥星贸易有限公司 | 济南拼接屏_山东液晶拼接屏_济南LED显示屏—维康国际官网 | 二手光谱仪维修-德国OBLF光谱仪|进口斯派克光谱仪-热电ARL光谱仪-意大利GNR光谱仪-永晖检测 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 |