<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 请求需要多长时间

      时间:2023-05-16

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

                上一篇:使用 Javascript 检索二进制文件内容,base64 对其进行编码并使用 Python 对其进行反向解码 下一篇:document.write() 覆盖文档?

                相关文章

              2. <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>

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