I have a script in javascript that load more information on page scroll down. The problem is that when I scroll down the script is executed twice and I have the same result twice or even more.
I want to execute the script once each time I scroll down and not execute it twice or even more each time.
This is the script:
$(window).scroll(function(){
var lastID = $('.load-more').attr('lastid');
if ($(window).scrollTop() == $(document).height() - $(window).height() && lastID != 0){
$.ajax({
type:'POST',
url:'getdata.php',
data:'id='+lastID,
beforeSend:function(html){
$('.load-more').show();
},
success:function(html){
$('.load-more').remove();
$('#list').append(html);
}
});
}
});
Aucun commentaire:
Enregistrer un commentaire