Is it possible to retrieve the MS / Latency from a “GET” request? (Javascript / Jquery)

南笙酒味 提交于 2019-12-06 05:20:19
jAndy

Just try it and check if those values you're measuring are the same or close to it.

Like

var startTime;
$.ajax
({
    // .. url, type, dataType, etc
    beforeSend: function(xhr)
    {
        startTime = +new Date();
    },
    complete: function(xhr, state)
    {
        var latency = (+new Date()) - startTime;
    }
});

I'm actually curious about that, so let us know your results. what you are getting is the difference in miliseconds.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!