In my web application, I use the $.ajax() request to load data from a database and display it in a browser. During query execution, I display a Loading Results ... message similar to this:
$.ajax({ // ... beforeSend: function() { $('#loading-results-message').show(); }, complete: function() { $('#loading-results-message').hide(); } });
It works great. However, if you do not load so much data, the query takes only a fraction of a second. In this case, the message is displayed only for a split second. This animation happens so fast that it is hard to recognize. Therefore, it would be great if it were possible to display the message only if the request took a certain amount of time, that is, a few seconds, at least, but not only a fraction of a second. Is it possible somehow? By the way, I use Django on the server side, if that matters.
source share