Reputation: 1267
I'm developing an ajax application using jQuery. And my question is the next one. Is there any way of to know how many seconds elapsed since the ajax call init?
I just want to change the loader message to "Still working..." when the ajax call is taking more than 10 seconds.
Thanks!
Upvotes: 0
Views: 297
Reputation: 21449
call the timer before the ajax call with setTimeout
setTimeout(function(){},10000);
Upvotes: 0
Reputation: 169383
$(window).ajaxInit(function() {
clearTimeout($.ns.tooLongTimer);
$.ns.tooLongTimer = setTimeout(function() {
$("#foo").text("TOO LONG");
}, 10000);
}).ajaxComplete(function() {
clearTimeout($.ns.tooLongTimer);
});
Upvotes: 4