i made a "scroll down, fire ajaxrequest, load more content" function.
but for it to work properly, and not fire many times in succession because the user scrolls more before the ajax data is loaded into the document, i need to prevent firing more ajaxrequests if there is any ajaxrequests loading.
code:
$(document).scroll(function() { var scrollBottom = $(document).height() - $(window).scrollTop(); if (scrollBottom < 3000) { var offset = parseInt($("#offset").html()) + 10; document.getElementById('offset').innerHTML = offset; $.ajax({ type: "POST", url: "/", data: "offset=" + offset <?=$ajaxextra?>, success: function(data){ $("#mainContent").append(data); }, error: function(e) { alert(e); } }); } }); This is what i think i need, in pseudocode:
if (scrollBottom < 3000 && !ajax.isLoading()) How do people do this kind of thing?