Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

JavaScript
<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>


HTML
<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>
Posted
Comments
[no name] 29-Oct-15 2:11am    
Try like below:

success:function(html){
if(html == "")
{
$('#show_more_main'+ID).remove();
$('.posts').append("No more Posts");
}else
{
$('#show_more_main'+ID).remove();
$('.posts').append(html);
}
}

1 solution

Just have one more link or div that says "No more posts" below your all the post., and on ajax success funtion you can show this.
Something like,
HTML
<div id="no-more-posts" style="display:none">
    No more posts to show.
</div>

JavaScript
success:function(html){
    $('#show_more_main'+ID).remove();
    $('.posts').append(html);
    $("#no-more-posts").fadeIn();
}



-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900