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

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

      2. <tfoot id='8sNRv'></tfoot>

        找出完成一个 Ajax 请求需要多长时间

        时间:2023-10-15
          <tbody id='OjOEH'></tbody>

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

      3. <tfoot id='OjOEH'></tfoot>
      4. <legend id='OjOEH'><style id='OjOEH'><dir id='OjOEH'><q id='OjOEH'></q></dir></style></legend>

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

                  本文介绍了找出完成一个 Ajax 请求需要多长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  找出特定 $.ajax() 请求所用时间的好方法是什么?

                  What is a good way to find out how long a particular $.ajax() request took?

                  我想获取此信息,然后将其显示在页面上的某处.

                  I would like to get this information and then display it on the page somewhere.

                  ANSWER??::::

                  我是 javascript 新手,如果您不想内联成功"函数(因为它将是一个更大的函数),这是我能想到的最好的方法.做这个?我觉得我把事情复杂化了……:

                  I'm new to javascript, this is the best that I could come up with if you don't want to inline the "success" function (because it will be a much bigger function) Is this even a good way to do this? I feel like I'm over complicating things...:

                  makeRequest = function(){
                      // Set start time
                      var start_time = new Date().getTime();
                  
                      $.ajax({ 
                          async : true,
                          success : getRquestSuccessFunction(start_time),
                      });
                  }
                  
                  getRquestSuccessFunction = function(start_time){
                      return function(data, textStatus, request){
                          var request_time = new Date().getTime() - start_time;
                      }
                  }
                  

                  推荐答案

                  @codemeit 是对的.他的解决方案如下所示,使用 jQuery 处理 ajax 请求.这会以毫秒为单位返回请求时间.

                  @codemeit is right. His solution looks something like the following using jQuery for the ajax request. This returns the request time in milliseconds.

                  var start_time = new Date().getTime();
                  
                  jQuery.get('your-url', data, function(data, status, xhr) {
                          var request_time = new Date().getTime() - start_time;
                  });
                  

                  这篇关于找出完成一个 Ajax 请求需要多长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Javascript 检索二进制文件内容,base64 对其进 下一篇:document.write() 覆盖文档?

                  相关文章

                  最新文章

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

                      <tfoot id='Ph5Ew'></tfoot>

                    1. <small id='Ph5Ew'></small><noframes id='Ph5Ew'>