久久久久久久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 上的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

                  設(shè)置

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

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

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

                  將其發(fā)送到 .php 將產(chǎn)生一個如下所示的數(shù)組:

                  數(shù)組([名稱] =>一些名字[電子郵件] =>一些電子郵件[電話] =>11111111[網(wǎng)站] =>一些網(wǎng)站[詳情] =>一些細節(jié)[發(fā)送] =>發(fā)送)

                  .php 將響應(yīng) {"message":"ok","code":0}{"message":"error","代碼":1}

                  現(xiàn)在這是預(yù)期的行為.這是我在 Chrome、IE 或 Safari 上得到的.

                  問題

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

                  數(shù)組([名稱] =>一些名字[電子郵件] =>一些電子郵件[電話] =>11111111[網(wǎng)站] =>一些網(wǎng)站[詳情] =>一些細節(jié))

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

                  解決方案

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

                  var data = new FormData(frm);data.append('發(fā)送', '發(fā)送');xhr.send(數(shù)據(jù));

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

                  問題

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

                  解決方案

                  根據(jù) WHATWG 規(guī)范,F(xiàn)ireFox 似乎是正確的.

                  FormDataXMLHttpRequest 規(guī)范> 構(gòu)造函數(shù)說:

                  <塊引用>

                  1. 如果給出 form,則將 fd 的條目設(shè)置為 構(gòu)造form 的表單數(shù)據(jù)集.

                  那么在構(gòu)造表單數(shù)據(jù)集的描述中,是這樣說的:

                  <塊引用>

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

                  表單中的按鈕只有在提交者的情況下才會包含在表單數(shù)據(jù)集中.但是當(dāng)這個算法從 FormData 構(gòu)造函數(shù)中執(zhí)行時,沒有指定提交者,所以表單數(shù)據(jù)集中不應(yīng)該包含任何按鈕.

                  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.

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

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                  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標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  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>
                            主站蜘蛛池模板: 日韩国产高清在线观看 | 成人国产精品色哟哟 | 日韩成人在线一区 | 在线观看成年视频 | 久久伊人影院 | 成人免费网站视频 | 欧美在线资源 | 国产日韩视频 | 色橹橹欧美在线观看视频高清 | 欧美美女爱爱 | 91精品导航| 免费一区| 久久久久久成人 | 日韩精品亚洲专区在线观看 | 国产片侵犯亲女视频播放 | 国产在线永久免费 | 国产一区二区三区在线观看免费 | 国产精品久久久久久久久久 | 在线一区二区三区 | 国产91精品久久久久久久网曝门 | 午夜影院 | 国产精品久久九九 | 国产91在线播放 | 99精品九九 | av手机在线播放 | 97国产爽爽爽久久久 | 琪琪午夜伦伦电影福利片 | 午夜免费精品视频 | 欧美成人一区二免费视频软件 | 国产亚洲一区二区三区 | 91精品国产综合久久福利软件 | 国产成人一区二区三区 | 国产在线麻豆精品入口 | 欧美一区二区三区,视频 | 成人福利视频网站 | 国产精品一卡二卡三卡 | 一a一片一级一片啪啪 | 日韩精品久久一区二区三区 | 天堂成人国产精品一区 | 99精品网站 | 久久国产精品免费一区二区三区 |