By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

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

P: 19
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.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.     $(document).on('click','.show_more',function(){
  4.         var ID = $(this).attr('id');
  5.         $('.show_more').hide();
  6.         $('.loding').show();
  7.         $.ajax({
  8.             type:'POST',
  9.             url:'mload_more.php',
  10.             data:'id='+ID,
  11.             success:function(html){
  12.                 $('#show_more_main'+ID).remove();
  13.                 $('.posts').append(html);
  14.             }
  15.         });
  16.  
  17.     });
  18. });
  19. </script>
Expand|Select|Wrap|Line Numbers
  1. <div class="show_more_main" id="show_more_main<?php echo $ID; ?>">
  2.  <span id="<?php echo $ID; ?>" class="show_more" title="Load more posts">Show more</span>
  3.  <span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
  4.  </div>
  5.  </div>
Oct 29 '15 #1

✓ answered by Dormilich

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.

Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
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.
Oct 29 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.