I would suggest something as simple as this:
function tooLong() {
$("#this-is-taking-too-long").show();
}
function performSomeAction() {
var timer = setTimeout(tooLong, 10000);
$.get('/foo/bar.php', {}, function() {
clearTimeout(timer);
});
}
source
share