因此,我试图从我的 mysql 数据库中的表中进行无休止的滚动,并且我拥有它,这样当到达页面底部时,它会要求将新数量的评论拉到新闻源中,但对于一些原因当它到达底部但只显示加载 gif 而没有新加载。任何我搞砸的帮助都会很棒。多谢你们
这是我的 jquery/ajax:
<script>
//Script to continue the home newsfeed after 10 posts
$(window).scroll(function() {
if($(window).scrollTop() === $(document).height() - $(window).height()) {
$('div#load_more_posts').show();
$.ajax( {
url: "load_more_posts.php?lastPost=" + $(".display_newsfeed:last").attr("id"),
success: function(html) {
if(html) {
$("#outputDiv").append(html);
$('div#load_more_posts').hide();
} else {
$('div#load_more_posts').replaceWith("<center>Finished loading all Posts!</center>")
}
}
});
}
});
</script>
这是调用新闻源的代码部分:
<div class="outputDiv">
<?php echo "$outputList"; ?><!-- Div for this output has been declared above in PHP before echoing -->
</div> <!-- END outputDiv -->
<div id='load_more_posts' style="display:none">
<center>
<img src="../../images/loading.gif" alt="Loading" />
</center>
</div>
最后,这是每个评论的新闻源显示 (display_newsfeed.php):
$review_query = mysql_query("SELECT * FROM `reviews` ORDER BY `review_date` DESC LIMIT 0,10");
while($review_row = mysql_fetch_assoc($review_query)){
$review_title = $review_row['review_title'];
$user_id = $review_row['user_id'];
$user_firstname = $review_row['user_firstname'];
$user_lastname = $review_row['user_lastname'];
$review_id = $review_row['review_id'];
$review_body = $review_row['review_body'];
$review_referral = $review_row['review_referral'];
$outputList .= '
<div class="display_newsfeed" id="'.$review_id.' display_newsfeed">
This code is each review
</div>
';