Note that there are some explanatory texts on larger screens.

plurals
  1. POEndless Scroll with Jquery, PHP, and Ajax
    primarykey
    data
    text
    <p>So I'm trying to impliment an endless scroll pulling from a table in my mysql database and I have it so that when the bottom of the page is reached it will call for a new number of reviews to be pulled to the newsfeed but for some reason when it gets to the bottom but just shows the loading gif and nothing new loads. Any help where I am messing up would be awesome. Thanks guys</p> <p>Here is my jquery/ajax:</p> <pre><code>&lt;script&gt; //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("&lt;center&gt;Finished loading all Posts!&lt;/center&gt;") } } }); } }); &lt;/script&gt; </code></pre> <p>Here is the part of the code where the newsfeed is called:</p> <pre><code>&lt;div class="outputDiv"&gt; &lt;?php echo "$outputList"; ?&gt;&lt;!-- Div for this output has been declared above in PHP before echoing --&gt; &lt;/div&gt; &lt;!-- END outputDiv --&gt; &lt;div id='load_more_posts' style="display:none"&gt; &lt;center&gt; &lt;img src="../../images/loading.gif" alt="Loading" /&gt; &lt;/center&gt; &lt;/div&gt; </code></pre> <p>And lastly, Here is the Newsfeed display for each review (display_newsfeed.php):</p> <pre><code>$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 .= ' &lt;div class="display_newsfeed" id="'.$review_id.' display_newsfeed"&gt; This code is each review &lt;/div&gt; '; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload