0

ウィンドウスクロールでajaxを使用してワードプレスの投稿をロードしたいのですが、Facebookのロード投稿に似ている必要がありますが、いくつかの問題で立ち往生しています。ウィンドウをスクロールすると、ウィンドウスクロールで投稿をロードするコードを使用しました投稿を1つずつ表示するのではなく、単一のウィンドウスクローラーにすべての投稿を表示します。これが私がこの目的のために使用するコードです。

誰でも私が問題を理解するのを手伝ってくれますか?

前もって感謝します

   <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 に答える