pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

                  問題描述

                  這里建議:https://gist.github.com/HenrikJoreteg/2502497,我正在嘗試將 onprogress 功能添加到我的 jQuery.ajax() 文件上傳中.上傳工作正常,并且 onprogress 事件正在觸發(fā),但不像我預(yù)期的那樣 - 不是在某個時間間隔重復(fù)觸發(fā),而是在上傳完成時只觸發(fā)一次.有沒有辦法指定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!');
                                  }
                              }
                          }
                      });
                  


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


                  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 的帖子標(biāo)記為已接受的答案.抱歉耽擱了.

                  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:

                  • 響應(yīng)進度(XmlHttpRequest.onprogress)
                    這是瀏覽器從服務(wù)器下載數(shù)據(jù)的時候.

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

                  請求進度 (XmlHttpRequest.upload.onprogress)
                  這是瀏覽器向服務(wù)器發(fā)送數(shù)據(jù)(包括 POST 參數(shù)、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)

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

                  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 選項參數(shù)必須是返回原生 XmlHttpRequest 對象以供 jQuery 使用的函數(shù).

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

                  這篇關(guān)于可以使用 xhrFields 將 onprogress 功能添加到 jQuery.ajax() 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                    <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="o0002ms" 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>
                            主站蜘蛛池模板: 真空泵维修保养,普发,阿尔卡特,荏原,卡西亚玛,莱宝,爱德华干式螺杆真空泵维修-东莞比其尔真空机电设备有限公司 | 生物风-销售载体,基因,质粒,ATCC细胞,ATCC菌株等,欢迎购买-百风生物 | 托盘租赁_塑料托盘租赁_托盘出租_栈板出租_青岛托盘租赁-优胜必达 | 不发火防静电金属骨料_无机磨石_水泥自流平_修补砂浆厂家「圣威特」 | CE认证_FCC认证_CCC认证_MFI认证_UN38.3认证-微测检测 CNAS实验室 | 机制砂选粉机_砂石选粉机厂家-盐城市助成粉磨科技有限公司 | 细沙回收机-尾矿干排脱水筛设备-泥石分离机-建筑垃圾分拣机厂家-青州冠诚重工机械有限公司 | 考勤系统_考勤管理系统_网络考勤软件_政企|集团|工厂复杂考勤工时统计排班管理系统_天时考勤 | 深圳富泰鑫五金_五金冲压件加工_五金配件加工_精密零件加工厂 | 北京银联移动POS机办理_收银POS机_智能pos机_刷卡机_收银系统_个人POS机-谷骐科技【官网】 | 食品质构分析仪-氧化诱导分析仪-瞬态法导热系数仪|热冰百科 | 国产离子色谱仪,红外分光测油仪,自动烟尘烟气测试仪-青岛埃仑通用科技有限公司 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 钢木实验台-全钢实验台-化验室通风柜-实验室装修厂家-杭州博扬实验设备 | 沟盖板_复合沟盖板厂_电力盖板_树脂雨水篦子-淄博拜斯特 | 恒压供水控制柜|无负压|一体化泵站控制柜|PLC远程调试|MCGS触摸屏|自动控制方案-联致自控设备 | 全自动端子机|刺破式端子压接机|全自动双头沾锡机|全自动插胶壳端子机-东莞市傅氏兄弟机械设备有限公司 | 自动部分收集器,进口无油隔膜真空泵,SPME固相微萃取头-上海楚定分析仪器有限公司 | 雨燕360体育免费直播_雨燕360免费NBA直播_NBA篮球高清直播无插件-雨燕360体育直播 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 洛阳网站建设_洛阳网站优化_网站建设平台_洛阳香河网络科技有限公司 | 玻璃钢型材-玻璃钢风管-玻璃钢管道,生产厂家-[江苏欧升玻璃钢制造有限公司] | 精密线材测试仪-电线电缆检测仪-苏州欣硕电子科技有限公司 | 瓶盖扭矩测试仪-瓶盖扭力仪-全自动扭矩仪-济南三泉中石单品站 | 校园文化空间设计-数字化|中医文化空间设计-党建|法治廉政主题文化空间施工-山东锐尚文化传播公司 | 水冷散热器_水冷电子散热器_大功率散热器_水冷板散热器厂家-河源市恒光辉散热器有限公司 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 手持式线材张力计-套帽式风量罩-深圳市欧亚精密仪器有限公司 | 无轨电动平车_轨道平车_蓄电池电动平车★尽在新乡百特智能转运设备有限公司 | 广东燎了网络科技有限公司官网-网站建设-珠海网络推广-高端营销型外贸网站建设-珠海专业h5建站公司「了了网」 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 洁净实验室工程-成都手术室净化-无尘车间装修-四川华锐净化公司-洁净室专业厂家 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 厂房出租_厂房出售_产业园区招商_工业地产&nbsp;-&nbsp;中工招商网 | 百方网-百方电气网,电工电气行业专业的B2B电子商务平台 | 煤粉取样器-射油器-便携式等速飞灰取样器-连灵动 | 陶瓷砂磨机,盘式砂磨机,棒销式砂磨机-无锡市少宏粉体科技有限公司 | 短信通106短信接口验证码接口群发平台_国际短信接口验证码接口群发平台-速度网络有限公司 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 体感VRAR全息沉浸式3D投影多媒体展厅展会游戏互动-万展互动 |