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>
                            主站蜘蛛池模板: 上海诺狮景观规划设计有限公司 | 三氯异氰尿酸-二氯-三氯-二氯异氰尿酸钠-优氯净-强氯精-消毒片-济南中北_优氯净厂家 | 液压升降货梯_导轨式升降货梯厂家_升降货梯厂家-河南东圣升降设备有限公司 | 深圳侦探联系方式_深圳小三调查取证公司_深圳小三分离机构 | 注塑模具_塑料模具_塑胶模具_范仕达【官网】_东莞模具设计与制造加工厂家 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 众品家具网-家具品牌招商_家具代理加盟_家具门户的首选网络媒体。 | 礼至家居-全屋定制家具_一站式全屋整装_免费量房设计报价 | 分类168信息网 - 分类信息网 免费发布与查询 | 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 袋式过滤器,自清洗过滤器,保安过滤器,篮式过滤器,气体过滤器,全自动过滤器,反冲洗过滤器,管道过滤器,无锡驰业环保科技有限公司 | 塑料撕碎机_编织袋撕碎机_废纸撕碎机_生活垃圾撕碎机_废铁破碎机_河南鑫世昌机械制造有限公司 | 冷镦机-多工位冷镦机-高速冷镦机厂家-温州金诺机械设备制造有限公司 | 胜为光纤光缆_光纤跳线_单模尾纤_光纤收发器_ODF光纤配线架厂家直销_北京睿创胜为科技有限公司 - 北京睿创胜为科技有限公司 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | 国标白水泥,高标号白水泥,白水泥厂家-淄博华雪建材有限公司 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 自清洗过滤器-全自动自清洗过反冲洗过滤器 - 中乂(北京)科技有限公司 | 煤机配件厂家_刮板机配件_链轮轴组_河南双志机械设备有限公司 | 据信,上课带着跳 D 体验-别样的课堂刺激感受引发网友热议 | 山东集装箱活动房|济南集装箱活动房-济南利森集装箱有限公司 | 北京乾茂兴业科技发展有限公司| ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 深圳侦探联系方式_深圳小三调查取证公司_深圳小三分离机构 | 环氧乙烷灭菌器_压力蒸汽灭菌器_低温等离子过氧化氢灭菌器 _低温蒸汽甲醛灭菌器_清洗工作站_医用干燥柜_灭菌耗材-环氧乙烷灭菌器_脉动真空压力蒸汽灭菌器_低温等离子灭菌设备_河南省三强医疗器械有限责任公司 | 渣土车电机,太阳能跟踪器电机,蜗轮蜗杆减速电机厂家-淄博传强电机 | 带锯机|木工带锯机圆木推台锯|跑车带锯机|河北茂业机械制造有限公司| | 数年网路-免费在线工具您的在线工具箱-shuyear.com | 淄博不锈钢无缝管,淄博不锈钢管-鑫门物资有限公司 | 越南专线物流_东莞国际物流_东南亚专线物流_行通物流 | 胶原检测试剂盒,弹性蛋白检测试剂盒,类克ELISA试剂盒,阿达木单抗ELISA试剂盒-北京群晓科苑生物技术有限公司 | 选矿设备-新型重选设备-金属矿尾矿重选-青州冠诚重工机械有限公司 | 防火窗_耐火窗_防火门厂家_防火卷帘门-重庆三乐门业有限公司 | 没斑啦-专业的祛斑美白嫩肤知识网站-去斑经验分享 | 选矿设备,选矿生产线,选矿工艺,选矿技术-昆明昆重矿山机械 | 悬浮拼装地板_幼儿园_篮球场_悬浮拼接地板-山东悬浮拼装地板厂家 | 东莞动力锂电池保护板_BMS智能软件保护板_锂电池主动均衡保护板-东莞市倡芯电子科技有限公司 | 河南不锈钢水箱_地埋水箱_镀锌板水箱_消防水箱厂家-河南联固供水设备有限公司 | 安驭邦官网-双向万能直角铣头,加工中心侧铣头,角度头[厂家直销] 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库-首页-东莞市傲马网络科技有限公司 | 海外仓系统|国际货代系统|退货换标系统|WMS仓储系统|海豚云 |