Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UPDATE
- Here is my triggering div
- `<a id="loadMore" href="#"><div id="loadmoreajaxloader" style=""><center><img src="ajax-loader.gif" /></center></div></a>`
- And here is the new function we are working on:
- `<script type="text/javascript">
- $(document).ready(function(){
- // Create the load content function
- function loadContent(){
- $.ajax({
- url: "loadmore.php?wall=<?php echo $wall; ?>&lastid=" + $(".postitem:last").attr("id"),
- success: function(html){
- if(html){
- $("#postswrapper").append(html);
- $('div#loadmoreajaxloader').hide();
- }else{
- $('div#loadmoreajaxloader').html('<center><font color="white">No more posts to show.</font></center>');
- }
- }
- });
- }
- // Set the onscroll event
- $(window).scroll(function(){
- if($(window).scrollTop()==$(document).height()-$(window).height()){
- $('div#loadmoreajaxloader').show();
- // IF YOU WANT TO LOAD MORE CONTENT WHEN SCROLLING THEN UNCOMMENT THE NEXT LINE
- loadContent();
- }
- });
- // Bind the click event to the Load More link
- $('#loadMore').click(function(){
- e.preventDefault();
- loadContent();
- });
- });
- </script>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement