Show 'no more posts' when loading posts using ajax php.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harman30
    New Member
    • Sep 2015
    • 19

    Show 'no more posts' when loading posts using ajax php.

    Below is the javascript part and load more button which I am using to load more posts from database it works fine I want to show a 'no more posts' message when all posts have been loaded but do not know how to do that exactly. Hope you guys can help.

    Code:
    <script type="text/javascript">
    $(document).ready(function(){
        $(document).on('click','.show_more',function(){
            var ID = $(this).attr('id');
            $('.show_more').hide();
            $('.loding').show();
            $.ajax({
                type:'POST',
                url:'mload_more.php',
                data:'id='+ID,
                success:function(html){
                    $('#show_more_main'+ID).remove();
                    $('.posts').append(html);
                }
            });
            
        });
    });
    </script>
    Code:
    <div class="show_more_main" id="show_more_main<?php echo $ID; ?>">
     <span id="<?php echo $ID; ?>" class="show_more" title="Load more posts">Show more</span>
     <span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
     </div>
     </div>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    if you want to know if there are no more post while fetching the last batch of posts, you need an extra query to check if there are more posts available.

    Comment

    Working...