Reputation: 15052
I want to load "more posts" dynamicly when user scrolls down the page to the last post. - this part is already done...
Thing is user can of course scroll back and forth, or just scroll again and again... This would cause multiple ajax requests when not needed yet.
How do I check if the same ajax call is not already running?
Upvotes: 0
Views: 1305
Reputation: 2844
Just use something like this:
var loading = false;
var postLoader = function() {
if (loading == false) {
loading = true;
$.ajax({
// ajax options...
}).always(function() {
loading = false;
});
}
}
Upvotes: 3