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

  • <small id='hL1ru'></small><noframes id='hL1ru'>

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

      <bdo id='hL1ru'></bdo><ul id='hL1ru'></ul>

    1. <legend id='hL1ru'><style id='hL1ru'><dir id='hL1ru'><q id='hL1ru'></q></dir></style></legend>
      1. 可以使用 xhrFields 將 onprogress 功能添加到 jQuery.

        Can onprogress functionality be added to jQuery.ajax() by using xhrFields?(可以使用 xhrFields 將 onprogress 功能添加到 jQuery.ajax() 嗎?)

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

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

        2. <legend id='bpIoU'><style id='bpIoU'><dir id='bpIoU'><q id='bpIoU'></q></dir></style></legend>

              • <bdo id='bpIoU'></bdo><ul id='bpIoU'></ul>
                  本文介紹了可以使用 xhrFields 將 onprogress 功能添加到 jQuery.ajax() 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  這里建議:https://gist.github.com/HenrikJoreteg/2502497,我正在嘗試將 onprogress 功能添加到我的 jQuery.ajax() 文件上傳中.上傳工作正常,并且 onprogress 事件正在觸發,但不像我預期的那樣 - 不是在某個時間間隔重復觸發,而是在上傳完成時只觸發一次.有沒有辦法指定onprogress刷新的頻率?或者,我是否正在嘗試做一些無法做到的事情?這是我的代碼:

                  As suggested here: https://gist.github.com/HenrikJoreteg/2502497, I'm trying to add onprogress functionality to my jQuery.ajax() file upload. The upload works fine, and the onprogress event is firing, but not as I expected--instead of firing repeatedly at some time interval, it's firing only once, when the upload has completed. Is there a way to specify the frequency of onprogress refreshes? Or, am I trying to do something that can't be done? Here's my code:

                      $.ajax(
                      {
                          async: true,
                          contentType: file.type,
                          data: file,
                          dataType: 'xml',
                          processData: false,
                          success: function(xml)
                          {
                              // Do stuff with the returned xml
                          },
                          type: 'post',
                          url: '/fileuploader/' + file.name,
                          xhrFields:
                          {
                              onprogress: function(progress)
                              {
                                  var percentage = Math.floor((progress.total / progress.totalSize) * 100);
                                  console.log('progress', percentage);
                                  if (percentage === 100)
                                  {
                                      console.log('DONE!');
                                  }
                              }
                          }
                      });
                  


                  嗯,已經好幾年了.我重新審視了這一點,并使用 GetFree 的答案,將我的代碼更新為以下內容:


                  Well, it's been a few years. I revisited this, and using GetFree's answer, I updated my code to the following:

                  $('#file_input').change(function()
                  {
                      var file = this.files[0];
                      $('#upload_button').click(funtion(e)
                      {
                          req = new XMLHttpRequest();
                          req.upload.addEventListener('progress', updateProgress, false);
                          req.addEventListener('load', transferComplete, false);
                          var url  = 'https://my.url'; 
                          req.open('POST', url, true);
                          req.setRequestHeader('Content-Type', myFileType);
                          req.setRequestHeader('Content-Length', myFileLength);
                          req.send(file);
                      });
                  );
                  function updateProgress(e)
                  {
                      var percent = Math.floor(e.loaded / e.total * 100);
                      console.log("percent = " + percent);
                  }
                  function transferComplete(e)
                  {
                      console.log("transfer complete");
                  }
                  

                  我已將 GetFree 的帖子標記為已接受的答案.抱歉耽擱了.

                  I have marked GetFree's post as the accepted answer. Sorry for the delay.

                  推薦答案

                  簡答:
                  不,你不能使用 xhrFields 做你想做的事.

                  長答案:

                  XmlHttpRequest 對象中有兩個進度事件:

                  There are two progress events in a XmlHttpRequest object:

                  • 響應進度(XmlHttpRequest.onprogress)
                    這是瀏覽器從服務器下載數據的時候.

                  • The response progress (XmlHttpRequest.onprogress)
                    This is when the browser is downloading the data from the server.

                  請求進度 (XmlHttpRequest.upload.onprogress)
                  這是瀏覽器向服務器發送數據(包括 POST 參數、cookie 和文件)的時候

                  The request progress (XmlHttpRequest.upload.onprogress)
                  This is when the browser is sending the data to the server (including POST parameters, cookies, and files)

                  在您的代碼中,您使用的是響應進度事件,但您需要的是請求進度事件.這就是你的做法:

                  In your code you are using the response progress event, but what you need is the request progress event. This is how you do it:

                  $.ajax({
                      async: true,
                      contentType: file.type,
                      data: file,
                      dataType: 'xml',
                      processData: false,
                      success: function(xml){
                          // Do stuff with the returned xml
                      },
                      type: 'post',
                      url: '/fileuploader/' + file.name,
                      xhr: function(){
                          // get the native XmlHttpRequest object
                          var xhr = $.ajaxSettings.xhr() ;
                          // set the onprogress event handler
                          xhr.upload.onprogress = function(evt){ console.log('progress', evt.loaded/evt.total*100) } ;
                          // set the onload event handler
                          xhr.upload.onload = function(){ console.log('DONE!') } ;
                          // return the customized object
                          return xhr ;
                      }
                  });
                  

                  xhr 選項參數必須是返回原生 XmlHttpRequest 對象以供 jQuery 使用的函數.

                  The xhr option parameter must be a function that returns a native XmlHttpRequest object for jQuery to use.

                  這篇關于可以使用 xhrFields 將 onprogress 功能添加到 jQuery.ajax() 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                    <tbody id='Ignry'></tbody>
                • <small id='Ignry'></small><noframes id='Ignry'>

                    <legend id='Ignry'><style id='Ignry'><dir id='Ignry'><q id='Ignry'></q></dir></style></legend>

                  1. <i id='Ignry'><tr id='Ignry'><dt id='Ignry'><q id='Ignry'><span id='Ignry'><b id='Ignry'><form id='Ignry'><ins id='Ignry'></ins><ul id='Ignry'></ul><sub id='Ignry'></sub></form><legend id='Ignry'></legend><bdo id='Ignry'><pre id='Ignry'><center id='Ignry'></center></pre></bdo></b><th id='Ignry'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ignry'><tfoot id='Ignry'></tfoot><dl id='Ignry'><fieldset id='Ignry'></fieldset></dl></div>
                    • <tfoot id='Ignry'></tfoot>
                            <bdo id='Ignry'></bdo><ul id='Ignry'></ul>
                            主站蜘蛛池模板: 色男人天堂av| 日本亚洲精品 | h免费观看| 国产中文字幕在线观看 | 97视频人人澡人人爽 | 日韩免费视频一区二区 | 97视频久久 | 国产精品久久久久久吹潮 | 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 欧美精品一区二区在线观看 | av大片在线观看 | 天天躁日日躁aaaa视频 | www国产亚洲精品久久网站 | 国产精品久久欧美久久一区 | 天堂久| 久久国产视频播放 | 国产欧美精品一区二区 | 99精品国产一区二区三区 | 97免费视频在线观看 | 日本成人三级电影 | 国产一级片免费在线观看 | 欧美精品久久一区 | 国产精品成人国产乱一区 | 成人av网站在线观看 | 欧美一级高潮片免费的 | 欧美综合久久 | 在线 丝袜 欧美 日韩 制服 | 国产精品一区二区久久 | 亚洲欧美精品久久 | 久久国产激情视频 | 久久精品在线 | 成人精品视频在线观看 | 看a网站| 欧美理伦片在线播放 | 亚洲午夜精品一区二区三区他趣 | 麻豆91精品91久久久 | 亚洲国产精品99久久久久久久久 | 性xxxxx| 天天草av| 国产日韩欧美一区 | www狠狠干 |