<legend id='DGn01'><style id='DGn01'><dir id='DGn01'><q id='DGn01'></q></dir></style></legend>
  • <tfoot id='DGn01'></tfoot>
          <bdo id='DGn01'></bdo><ul id='DGn01'></ul>
      1. <small id='DGn01'></small><noframes id='DGn01'>

      2. <i id='DGn01'><tr id='DGn01'><dt id='DGn01'><q id='DGn01'><span id='DGn01'><b id='DGn01'><form id='DGn01'><ins id='DGn01'></ins><ul id='DGn01'></ul><sub id='DGn01'></sub></form><legend id='DGn01'></legend><bdo id='DGn01'><pre id='DGn01'><center id='DGn01'></center></pre></bdo></b><th id='DGn01'></th></span></q></dt></tr></i><div id='DGn01'><tfoot id='DGn01'></tfoot><dl id='DGn01'><fieldset id='DGn01'></fieldset></dl></div>

        XmlHttpRequest onprogress 间隔

        时间:2023-10-15
          <tbody id='3vyrQ'></tbody>
        <tfoot id='3vyrQ'></tfoot>
          <bdo id='3vyrQ'></bdo><ul id='3vyrQ'></ul>
          1. <legend id='3vyrQ'><style id='3vyrQ'><dir id='3vyrQ'><q id='3vyrQ'></q></dir></style></legend>

              • <i id='3vyrQ'><tr id='3vyrQ'><dt id='3vyrQ'><q id='3vyrQ'><span id='3vyrQ'><b id='3vyrQ'><form id='3vyrQ'><ins id='3vyrQ'></ins><ul id='3vyrQ'></ul><sub id='3vyrQ'></sub></form><legend id='3vyrQ'></legend><bdo id='3vyrQ'><pre id='3vyrQ'><center id='3vyrQ'></center></pre></bdo></b><th id='3vyrQ'></th></span></q></dt></tr></i><div id='3vyrQ'><tfoot id='3vyrQ'></tfoot><dl id='3vyrQ'><fieldset id='3vyrQ'></fieldset></dl></div>
                • <small id='3vyrQ'></small><noframes id='3vyrQ'>

                  本文介绍了XmlHttpRequest onprogress 间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 XmlHttpRequests 将图像上传到服务器,我想向用户显示这些上传的进度.

                  I'm using XmlHttpRequests to upload images to a server and I'd like to show the user the progress of these uploads.

                  不幸的是,对我的 onprogress-event 处理程序的调用之间的间隔太大.对于 500k 的图像,通常只调用一次或两次 onprogress.

                  Unfortunately the interval between calls to my onprogress-event handler is too large. Usually onprogress is called only once or twice for a 500k image.

                  这是我的代码:

                  /* This function is not called often enough */
                  function progress(e){
                      console.log('Uploading: ' + Math.round((e.loaded / e.total) * 100) + ' %');
                  }
                  
                  var xhr = new XMLHttpRequest();
                  xhr.upload.addEventListener('progress', progress, false);
                  xhr.send(data);
                  

                  是否可以更改此行为,或者是否可以在浏览器实现中的某处对其进行硬编码?

                  Can this behaviour be changed or is this hardcoded somewhere in the browser implementation?

                  推荐答案

                  W3 在他们的 XMLHttpRequest 级别 2 文档.显然,跨浏览器的不同级别的一致性是可以预料的.

                  The W3 sets forth the following guidelines in their XMLHttpRequest Level 2 document. Obviously varying levels of conformance across browsers are to be expected.

                  上传:

                  当请求实体正文被上传并且上传完成标志为假时,排队一个任务以在 XMLHttpRequestUpload 对象上触发一个名为 progress 的进度事件,大约每 50 毫秒或传输的每个字节,以最不频繁的为准.- W3 XMLHttpRequest Level 2(粗体表示强调)

                  While the request entity body is being uploaded and the upload complete flag is false, queue a task to fire a progress event named progress at the XMLHttpRequestUpload object about every 50ms or for every byte transmitted, whichever is least frequent. - W3 XMLHttpRequest Level 2 (Bolded for emphasis)

                  下载:

                  如果说要发出进度通知,则在下载过程中,排队一个任务以触发一个名为 progress 的进度事件,大约每 50 毫秒或接收到的每个字节,以最不频繁的为准.- W3 XMLHttpRequest Level 2(粗体表示强调)

                  When it is said to make progress notifications, while the download is progressing, queue a task to fire a progress event named progress about every 50ms or for every byte received, whichever is least frequent. - W3 XMLHttpRequest Level 2 (Bolded for emphasis)

                  我不知道自定义此功能的 api.

                  I am not aware of an api to customize this functionality.

                  这篇关于XmlHttpRequest onprogress 间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tbody id='F4ewJ'></tbody>

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

                    <legend id='F4ewJ'><style id='F4ewJ'><dir id='F4ewJ'><q id='F4ewJ'></q></dir></style></legend>
                    • <bdo id='F4ewJ'></bdo><ul id='F4ewJ'></ul>

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