How to keep track of how long the ajax request is. It is clear that there is a timeout , but it sets the maximum execution time.
I also need if the request is executed for more than 1 second, for example, to show the cap - a rotating thing. Usually requests pass quickly. And so that with each dispatch a blinker “twinkle” is not the case. But if the request for some reason is executed for a long time, then it would be good to notify the user - to show the "cool". How to do it?
Those. How to show the "cool" not immediately after the start of the request, but after some time?
$.ajax({ type: "POST", url: 'url', async: 'false', timeout: 20000, dataType: 'html', data: data, success: function(result){message(result);}, error: function(err){console.log(err);} }); $( document ).ajaxComplete(function() { jQuery('.animationload').addClass('hide'); //прячу крутёлку });