Advertisement
Guest User

function loadmore

a guest
Mar 29th, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UPDATE
  2. Here is my triggering div
  3. `<a id="loadMore" href="#"><div id="loadmoreajaxloader" style=""><center><img src="ajax-loader.gif" /></center></div></a>`
  4.  
  5. And here is the new function we are working on:
  6.  
  7. `<script type="text/javascript">
  8. $(document).ready(function(){
  9. // Create the load content function
  10. function loadContent(){
  11.     $.ajax({
  12.         url: "loadmore.php?wall=<?php echo $wall; ?>&lastid=" + $(".postitem:last").attr("id"),
  13.         success: function(html){
  14.             if(html){
  15.                 $("#postswrapper").append(html);
  16.                 $('div#loadmoreajaxloader').hide();
  17.             }else{
  18.                 $('div#loadmoreajaxloader').html('<center><font color="white">No more posts to show.</font></center>');
  19.             }
  20.         }
  21.     });
  22. }
  23. // Set the onscroll event
  24. $(window).scroll(function(){
  25.     if($(window).scrollTop()==$(document).height()-$(window).height()){
  26.         $('div#loadmoreajaxloader').show();
  27.         // IF YOU WANT TO LOAD MORE CONTENT WHEN SCROLLING THEN UNCOMMENT THE NEXT LINE
  28.         loadContent();
  29.     }
  30. });
  31. // Bind the click event to the Load More link
  32. $('#loadMore').click(function(){
  33.     e.preventDefault();
  34.     loadContent();
  35. });
  36. });
  37. </script>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement