0

i want to load wordpress posts using ajax on window scroll, it must be similar to facebook loading posts,But i am in stuck with some issue, I have used the code that is loading the posts on window scroll, when i scroll window it shows the posts, but rather showing one by one posts it shows the all posts on single window scroller. Here is the code which i use for this purpose.

Can any one help me to figure out the issue.

Thanks in advance

   <script type="text/javascript">
   jQuery(document).ready(function ($) {
   $(window).scroll(function () {
   var ajaxURL = '<?php echo get_admin_url(); ?>admin-ajax.php';
   var post_id = $('.ajaxclick').attr('id');
        $.ajax({
        url: ajaxURL,
        type: 'POST',
        cache:false,
        beforeSend: function() {
        $("#loading_animation").hide();
        $("#ajaxloader").show();

        },
        complete: function() {
                $("#loading_animation").show();
                $("#ajaxloader").hide();

        },  
        data:   {
                action: 'load_content',
                post_id: post_id,                   
                },
        success: function(response){
        // var i = setInterval( function() {
        // jQuery("#loading_animation").html(response); //Whatever the php page to do the query against here
        // }, 5000 //timeout in miliseconds
            // );

                jQuery("#loading_animation").html(response);
         return false;
                    }   
            });


  });
  });

  </script>
4

1 回答 1

1

您可以查看 Paul Irish 的精彩插件 - Infinite Scroll:

http://www.infinite-scroll.com/

我相信它完全符合您的要求。

于 2013-04-30T16:51:05.713 回答