I am trying to build a scrolling system for my website. This is what I have com up with ...
$.ajaxSetup({ cache: false });
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
picturesCount = $(".Picture-1A").length;
allPicturesCount = $("#allPicturesCount").text();
alert('picturesloaded:' + picturesCount + ' PicturesDB: ' + allPicturesCount)
if(picturesCount < allPicturesCount){
$.post('ajax/load-latest-pictures.php', {pictures_loaded:picturesCount}, function(data){
if(data){
$("#loadMore").append(data);
}
});
}else{
$("#loadMore").append("<center>There are no pictures.</center>");
return;
}
}
});
I am having problem when all the pictures have been appended and there is nothing left. The problem is every time I get to the bottom of the page 'There are no pictures.' get appended more than once. How can I append it once? Try it on your browser and tell me what you think.
The second question is that I am having problems with IE, all versions. Evertime I get to the bottom and I have pictures left it loads it more than once. I searched for an answer and all I got was that IE have problems with cache. So I added the $.ajaxSetup cache option to false. But the problem still exist.