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

  • <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 国产99久久精品一区二区永久免费 | 欧美色综合天天久久综合精品 | 久久综合国产 | 毛片a级| 精品熟人一区二区三区四区 | 欧美色人 | 91精品国产综合久久久久蜜臀 | 国产乱码精品一区二区三区忘忧草 | 一级片免费视频 | 亚洲国产成人精品女人久久久野战 | 精品免费av | 成人一区在线观看 | 91亚洲视频在线 | 婷婷久久综合 | 国产精品成人一区二区三区夜夜夜 | 久久的色 | 日韩高清一区 | 亚洲精品一二三区 | 秋霞在线一区二区 | 成人精品视频在线观看 | 国产最新视频在线 | 国内精品久久久久久影视8 最新黄色在线观看 | 在线观看www| 99热这里都是精品 | www.天天操 | 伊人狠狠| 国产精品国产三级国产播12软件 | 色欧美片视频在线观看 | 99精品视频一区二区三区 | 亚洲欧美精品 | 女同av亚洲女人天堂 | 国产精品久久久久久久毛片 | 久久久成人免费一区二区 | 亚洲精品第一页 | 国产日韩精品视频 | 九九综合九九 | 欧美日韩视频在线第一区 | 国产精品一区三区 | 91免费版在线| 久久久久久久国产 | 天天草天天射 |