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="31lzbz3" 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="txfvfv1" 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="b7j5bbz" 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>
                            主站蜘蛛池模板: 洗瓶机厂家-酒瓶玻璃瓶冲瓶机-瓶子烘干机-封口旋盖压盖打塞机_青州惠联灌装机械 | 代做标书-代写标书-专业标书文件编辑-「深圳卓越创兴公司」 | 陕西安玻璃自动感应门-自动重叠门-磁悬浮平开门厂家【捷申达门业】 | 数码管_LED贴片灯_LED数码管厂家-无锡市冠卓电子科技有限公司 | 奥运星-汽车性能网评-提供个性化汽车资讯 | 【ph计】|在线ph计|工业ph计|ph计厂家|ph计价格|酸度计生产厂家_武汉吉尔德科技有限公司 | 长沙印刷厂-包装印刷-画册印刷厂家-湖南省日大彩色印务有限公司 青州搬家公司电话_青州搬家公司哪家好「鸿喜」青州搬家 | 气动隔膜阀_气动隔膜阀厂家_卫生级隔膜阀价格_浙江浙控阀门有限公司 | SF6环境监测系统-接地环流在线监测装置-瑟恩实业 | 无线对讲-无线对讲系统解决方案-重庆畅博通信 | 篮球地板厂家_舞台木地板品牌_体育运动地板厂家_凯洁地板 | 耐火砖厂家,异形耐火砖-山东瑞耐耐火材料厂 | 缠膜机|缠绕包装机|无纺布包装机-济南达伦特机械设备有限公司 | 杭州荣奥家具有限公司-浙江办公家具,杭州办公家具厂 | 在线悬浮物浓度计-多参数水质在线检测仪-上海沃懋仪表科技有限公司 | 净化车间_洁净厂房_净化公司_净化厂房_无尘室工程_洁净工程装修|改造|施工-深圳净化公司 | 采暖炉_取暖炉_生物质颗粒锅炉_颗粒壁炉_厂家加盟批发_烟台蓝澳采暖设备有限公司 | 全自动包装秤_全自动上袋机_全自动套袋机_高位码垛机_全自动包装码垛系统生产线-三维汉界机器(山东)股份有限公司 | 全温恒温摇床-水浴气浴恒温摇床-光照恒温培养摇床-常州金坛精达仪器制造有限公司 | 防渗土工膜|污水处理防渗膜|垃圾填埋场防渗膜-泰安佳路通工程材料有限公司 | 涿州网站建设_网站设计_网站制作_做网站_固安良言多米网络公司 | 德国EA可编程直流电源_电子负载,中国台湾固纬直流电源_交流电源-苏州展文电子科技有限公司 | SOUNDWELL 编码器|电位器|旋转编码器|可调电位器|编码开关厂家-广东升威电子制品有限公司 | 扫地车厂家-山西洗地机-太原电动扫地车「大同朔州吕梁晋中忻州长治晋城洗地机」山西锦力环保科技有限公司 | 求是网 - 思想建党 理论强党 | 深圳湾1号房价_深圳湾1号二手房源 | 贴板式电磁阀-不锈钢-气动上展式放料阀-上海弗雷西阀门有限公司 工业机械三维动画制作 环保设备原理三维演示动画 自动化装配产线三维动画制作公司-南京燃动数字 | 股票入门基础知识_股票知识_股票投资大师_格雷厄姆网 | 工业废水处理|污水处理厂|废水治理设备工程技术公司-苏州瑞美迪 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 珠海冷却塔降噪维修_冷却塔改造报价_凉水塔风机维修厂家- 广东康明节能空调有限公司 | 溶氧传感器-pH传感器|哈美顿(hamilton) | China plate rolling machine manufacturer,cone rolling machine-Saint Fighter | 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 强效碱性清洗剂-实验室中性清洗剂-食品级高纯氮气发生器-上海润榕科学器材有限公司 | 粘度计NDJ-5S,粘度计NDJ-8S,越平水分测定仪-上海右一仪器有限公司 | 首页_欧瑞传动官方网站--主营变频器、伺服系统、新能源、软起动器、PLC、HMI | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 培训中心-翰香原香酥板栗饼加盟店总部-正宗板栗酥饼技术 | 地源热泵一体机,地源热泵厂家-淄博汇能环保设备有限公司 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 小型数控车床-数控车床厂家-双头数控车床 |