Standard Click Request
$("#load").click(function() { $.ajax({ beforeSend: function (data) { $('#loading_box').show(); }, success: function (j) { $('#loading_box').hide(); $('#content').html(j.html); } }); return false; }); I think in the beforeSend you need to show the download indicator, inside setTimeout . But what if the success event comes with the command to hide the indicator, and then the timeout ends and the indicator shows when it is no longer needed?
The preloader must be shown at boot, longer than a certain time and hidden when the answer came. In addition, you need to consider that it is possible to click again and launch the request, it may also not be successful. It is obvious that in all these cases, the timeout must be cleared and restarted at the last request.
Can you suggest an algorithm or sample code? Or perhaps there is something ready for such an advanced indicator output?
done: function() {}eventdone: function() {}. It doesn’t matter if the server returns a response or the time goes out, it will work when the request is completed. NosetTimeoutneeded. And in beforeSend is not a loading indicator, but just something like “please wait” - Mr. BlackContent-Lengthheader and its length in the response from the server. If the question is in this, it is in the download indicator that I can give a detailed answer. And in ajax there is an event likecomplete: function() {}. Fired upon completion of the request - Mr. Blackreturn false. Instead of the link button chtoli? - Mr. Black