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

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

    <tfoot id='FLDrx'></tfoot>
      • <bdo id='FLDrx'></bdo><ul id='FLDrx'></ul>

    1. <legend id='FLDrx'><style id='FLDrx'><dir id='FLDrx'><q id='FLDrx'></q></dir></style></legend>

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

      Find out how long an Ajax request took to complete(找出完成一个 Ajax 请求需要多长时间)

    3. <small id='WN6iW'></small><noframes id='WN6iW'>

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

                <tbody id='WN6iW'></tbody>

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

                <tfoot id='WN6iW'></tfoot>
                <legend id='WN6iW'><style id='WN6iW'><dir id='WN6iW'><q id='WN6iW'></q></dir></style></legend>
                本文介绍了找出完成一个 Ajax 请求需要多长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                找出特定 $.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 请求需要多长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
                XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
                Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
                How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
                How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
                quot;Origin null is not allowed by Access-Control-Allow-Originquot; in Chrome. Why?(“Access-Control-Allow-Origin 不允许 Origin null在铬.为什么?)

                <tfoot id='7yMNw'></tfoot>

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

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

                        <tbody id='7yMNw'></tbody>
                    1. <legend id='7yMNw'><style id='7yMNw'><dir id='7yMNw'><q id='7yMNw'></q></dir></style></legend>