Too much recursion on ajax call

I am usining masonry view to display content with infinite scrolling functionality.
Masonry view part is working fine. For infinite scroll I have tried infinitescroll js
or on the basis of scroll as I have written below code.

Problem :- After first scroll I am facing too much recursion problem.

Read More
jQuery(document).ready(function($) {
    var $container = jQuery('.main_container');
    $container.imagesLoaded(function(){
      // options
      $container.masonry({
        itemSelector: '.pin',
        isAnimated: true,
        isFitWidth: true,
        isAnimatedFromBottom: true
      });
    });

    //for infinite scrollings
    jQuery(window).scroll(function() {
        if(jQuery(window).scrollTop() + jQuery(window).height() == jQuery(document).height()) {
        alert("bottom!");
        ajaxurl = "script url here";
        var data = {start:startLimit,end:endLimit};
        jQuery.get(ajaxurl, data, function(response) {
             var $boxes = $(response);
             $('.main_container').append( $boxes ).masonry( 'appended', $boxes );
        });
        }
    });
});

I am trying this on wordpress admin section plugin.

Related posts

Leave a Reply

1 comment

  1. After step-by-step checking I found solution , Cause of the problem I am using animate effect in masonry which is conflict some how with wordpress plugin view js.

     $container.imagesLoaded(function(){
      // options
      $container.masonry({
        itemSelector: '.pin',
        isAnimated: false,
        isFitWidth: true,
        isAnimatedFromBottom: false
      });
    });