title: rails infinate scrolling loads 2 times single page
body: <p>Hi i am trying to create a infinite scrolling in rails with pagination gem. no other specific gem i am using for this.it works fine with loading a content but i loads a single page means next page 2 times instead of one time. even the request to the server goes from the page only once response also only once but content is coming 2 times.</p>
  
  <p>i have tried to look how it returning the content 2 times but unable to find how it's working. some one can help me ??</p>
  
  <p><strong>JS to send a request for a 2nd page while Scrolling the page</strong> </p>
  
  <pre><code>$(window).on 'scroll', -&gt;
      more_posts_url = $('.pagination .next_page').attr('href')
      if more_posts_url &amp;&amp; $(window).scrollTop() &gt; $(document).height() - $(window).height() - 60
        $('.pagination').html('&lt;p&gt;Loading......&lt;/p&gt;')
        $.ajax more_posts_url,
        type: 'get'
        dataType: 'script'
      return
  </code></pre>
  
  <p><strong>the controller where the request will received</strong> </p>
  
  <pre><code> def show
  @follow_unfollow = FollowerDetail.new
  @songs = Song.user_filter(@user.id).paginate(:page =&gt; params[:page], :per_page =&gt; 2)
  respond_to do |format|
      format.html { }
      format.js { }
  end
  </code></pre>
  
  <p>end</p>
  
  <p><strong>the response JS from this controller</strong> </p>
  
  <pre><code>$('#my_songs').append("&lt;%= j render partial: 'songshow' , :collection =&gt; @songs %&gt;");
  &lt;% if @songs.next_page %&gt;
     $('#infinite-scrolling').replaceWith('&lt;%= j will_paginate @songs %&gt;');
  &lt;% else %&gt;
     $('.pagination').remove();
  &lt;% end %&gt;
  </code></pre>