var $isFetchingNotes = false;
$(window).scroll(function(){
if($("-sharploader-blog").hasClass("nomore")) {
return false;
}
var $scroll = $(window).scrollTop();
var $docHeight = $(document).height();
var $winHeight = $(window).height();
if($scroll === $docHeight - $winHeight){
if(!$isFetchingNotes) {
$isFetchingNotes = true;
$("-sharploader-blog").html("<img src="/images/lazyload40.svg">");
var lastDiv = $(".data-display-blog:last");
var lastId = $(".data-display-blog:last").attr("id");
var type = $(".data-display-blog:last").attr("data-type");
var query = $(".data-display-blog:last").attr("data-query");
var dataTo = "lastid="+lastId+"&type="+type+"&query="+query;
$.ajax({
type: "POST",
url:"app",
data: dataTo,
cache: false,
success: function(data){
if(data != ""){
lastDiv.after(data);
}else{
$("-sharploader-blog").addClass("nomore").html("nodata");
}
},
complete: function () {
$isFetchingNotes = false;
}
});
}
}
});
when I find that scroll slips to the bottom, he will not run $("- sharploader-blog"). AddClass ("nomore"). Html (" nodata") even if the backend data is
this paragraph? empty
;
I added the alert event in my profile, but none of them responded.
but I use Google inspect to check < div id= "- sharploader-blog" > < / div >
every time it slips, there will be a shock. (it may later be found that $("- sharploader-blog"). Html ("");
)
how did this happen? I make sure that the value given at the back end is null.
even if I become like this:
if(data != ""){
lastDiv.after(data);
}else if(data == ""){
$("-sharploader-blog").addClass("nomore").html("no-data");
}
there is still no response.
charge:
how can I start issuing ajax requests before I hit the bottom?