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

    1. <tfoot id='7ZUnY'></tfoot>
      <legend id='7ZUnY'><style id='7ZUnY'><dir id='7ZUnY'><q id='7ZUnY'></q></dir></style></legend>

        <bdo id='7ZUnY'></bdo><ul id='7ZUnY'></ul>

      <small id='7ZUnY'></small><noframes id='7ZUnY'>

      1. <i id='7ZUnY'><tr id='7ZUnY'><dt id='7ZUnY'><q id='7ZUnY'><span id='7ZUnY'><b id='7ZUnY'><form id='7ZUnY'><ins id='7ZUnY'></ins><ul id='7ZUnY'></ul><sub id='7ZUnY'></sub></form><legend id='7ZUnY'></legend><bdo id='7ZUnY'><pre id='7ZUnY'><center id='7ZUnY'></center></pre></bdo></b><th id='7ZUnY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7ZUnY'><tfoot id='7ZUnY'></tfoot><dl id='7ZUnY'><fieldset id='7ZUnY'></fieldset></dl></div>

        為什么輸入 type=file 不能與 $.ajax 一起使用?

        Why input type=file not working with $.ajax?(為什么輸入 type=file 不能與 $.ajax 一起使用?)
        • <bdo id='pGly5'></bdo><ul id='pGly5'></ul>

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

                  <tbody id='pGly5'></tbody>
                1. <tfoot id='pGly5'></tfoot>
                  <legend id='pGly5'><style id='pGly5'><dir id='pGly5'><q id='pGly5'></q></dir></style></legend>
                  <i id='pGly5'><tr id='pGly5'><dt id='pGly5'><q id='pGly5'><span id='pGly5'><b id='pGly5'><form id='pGly5'><ins id='pGly5'></ins><ul id='pGly5'></ul><sub id='pGly5'></sub></form><legend id='pGly5'></legend><bdo id='pGly5'><pre id='pGly5'><center id='pGly5'></center></pre></bdo></b><th id='pGly5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pGly5'><tfoot id='pGly5'></tfoot><dl id='pGly5'><fieldset id='pGly5'></fieldset></dl></div>

                2. 本文介紹了為什么輸入 type=file 不能與 $.ajax 一起使用?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我在表單中有一個(gè) <s:file> 標(biāo)簽,它生成一個(gè) HTML <input type="file">.當(dāng)我通過(guò)表單提交(例如提交按鈕等)提交表單時(shí),動(dòng)作方法中的一切正常.但是,當(dāng)我將代碼更改為:

                  I have a <s:file> tag inside the form which generates a HTML <input type="file">. When I submit the form via form submission (e.g. submit button, etc.) everything works fine in the action method. However, when I change my code to:

                  $.ajax({
                      url: "actionClass!actionMethodA.action",
                      type: "POST",
                      error: function(XMLHttpRequest, textStatus, errorThrown) {
                                  alert('Error ' + textStatus);
                                  alert(errorThrown);
                                  alert(XMLHttpRequest.responseText);
                              },
                      data: $(form).serialize(),
                      success: function(data) {
                                  ...
                              }
                  });
                  

                  在后端,file字段總是null.

                  file 字段在 action 類(lèi)中定義如下(帶有 setter 和 getter):

                  The file field is defined in the action class as follow (with setter and getter):

                  private File impFileUrl;
                  

                  是不是因?yàn)楝F(xiàn)在表單被序列化了,導(dǎo)致后端不能再正確設(shè)置文件字段?

                  Is it because now the form is serialized so that the file field can no longer be set properly in the backend?

                  推薦答案

                  這是因?yàn)?jQuery.serialize() 只序列化輸入元素,而不是其中的數(shù)據(jù).

                  It is because jQuery.serialize() serializes only input elements, not the data in them.

                  只有成功的控件"被序列化為字符串.不提交按鈕值被序列化,因?yàn)楸韱尾皇鞘褂冒粹o.對(duì)于要包含在序列化的表單元素的值字符串,元素必須有一個(gè)名稱(chēng)屬性.復(fù)選框的值和單選按鈕(單選"或復(fù)選框"類(lèi)型的輸入)包括在內(nèi)僅當(dāng)它們被檢查時(shí).來(lái)自文件選擇元素的數(shù)據(jù)不是序列化.

                  Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

                  但這并不意味著你不能用ajax上傳文件.可能會(huì)使用其他功能或插件來(lái)發(fā)送 FormData 對(duì)象.

                  But it doesn't mean that you can't upload files with ajax. Additional features or plugins might be used to send FormData object.

                  如果您設(shè)置了正確的選項(xiàng),您也可以將 FormData 與 jQuery 一起使用:

                  You can also use FormData with jQuery if you set the right options:

                  var fd = new FormData(document.querySelector("form"));
                  fd.append("CustomField", "This is some extra data");
                  $.ajax({
                    url: "actionClass!actionMethodA.action",
                    type: "POST",
                    data: fd,
                    processData: false,  // tell jQuery not to process the data
                    contentType: false   // tell jQuery not to set contentType
                  });
                  

                  這篇關(guān)于為什么輸入 type=file 不能與 $.ajax 一起使用?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 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 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                    <tbody id='gxrhC'></tbody>

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

                      <tfoot id='gxrhC'></tfoot>

                    1. <legend id='gxrhC'><style id='gxrhC'><dir id='gxrhC'><q id='gxrhC'></q></dir></style></legend>
                        • <small id='gxrhC'></small><noframes id='gxrhC'>

                            <bdo id='gxrhC'></bdo><ul id='gxrhC'></ul>
                            主站蜘蛛池模板: 中文字幕亚洲欧美 | 国产精品精品久久久久久 | 色综合天天天天做夜夜夜夜做 | 成人免费观看视频 | 欧美v日韩| 国产激情视频在线 | 最新日韩在线 | 国产精品久久久久久久午夜片 | 97免费在线观看视频 | a欧美| 男人的天堂在线视频 | 久久久久无码国产精品一区 | 日韩一区二区三区精品 | 久久精品国产亚洲a | 国产精品成人一区二区三区 | 91社区在线观看播放 | 在线第一页 | 国产精品美女一区二区三区 | 国产精品国产馆在线真实露脸 | 一区中文字幕 | 91精品一区二区三区久久久久久 | 成人欧美一区二区三区1314 | 欧美一区二区三区的 | 久久欧美高清二区三区 | 91偷拍精品一区二区三区 | www.亚洲精品 | 北条麻妃av一区二区三区 | 一本一道久久a久久精品蜜桃 | 久久久国产一区二区三区 | 欧美综合一区 | 久久久久无码国产精品一区 | 99综合| 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 99亚洲国产精品 | 91免费在线 | 久久国产精品一区二区三区 | 成人免费视频网站 | 日韩欧美国产一区二区三区 | 欧美激情一区二区 | 羞羞视频在线观看免费观看 | 97综合在线 |