For some weird reason the ajax function below is firing twice. The loadMoreResults(); function is used to retrieve data from server. I tracked the data sent to the server using google developer tool it showed that the ajax request was fired twice in a row. I guess this happens when the user scroll fast.
//Executed when user has scrolled bottom of the page
$(window).scroll(function (e) {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
loadMoreResults();
}
});
Any idea on how to prevent this from happening? Appreciate your help.