title: Jquery scroll is not picking changed variable value to be sent to ajax
body: <p>I am not a regular programmer and has learnt whatever programming I know by google or by asking things here from Stackoverflow.</p>
  
  <p>I am trying to create a ajax function which will fetch feeds from database on scrolling based on selected parameter. User can select either to select public feeds or personal feeds. His chosen value is updated in hidden text field. Code follows as below. </p>
  
  <p><a href="https://i.stack.imgur.com/3Yglk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Yglk.png" alt="enter image description here"></a></p>
  
  <pre><code>//feed menu switch between personal and public  
  $('.menu_selection').iCheck({
      checkboxClass: 'icheckbox_square',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
  });         
  $("body").on("ifChecked",".menu_selection",function(){
      var feed_menu_selected = $(this).val();             
      $("#feed_menu_selected").val(feed_menu_selected);       
      $("#member_menu_area").html(loader);
      IndexFeederLoader('0','0','0'); 
  }); 
  </code></pre>
  
  <p>Now this is function which is fetching records where <code>group_no</code> is the record set being fetched, <code>total_m_group</code> is total number of records, <code>feed_menu_selected</code> is the choice between public or private.</p>
  
  <pre><code>function IndexFeederLoader(group_no,total_m_group,movie_shown){
  
  var feed_menu_selected = $("#feed_menu_selected").val();
  
  $.ajax({            
      url: '../index-feeds.php',
      type: "POST", 
      dataType:"text", 
      data: 'feed_menu_selected='+feed_menu_selected+'&amp;group_no='+group_no+'&amp;movie_shown='+movie_shown,               
      cache: false, 
      async: false, 
      success: function(data){
          if(group_no == 0)
              {
                  $("#member_menu_area").html(data);
                  //when personal is checked and not signed in
                  var notsigned = $(data).filter('#notsigned').text();
                  if( notsigned !== '')
                      {
                          $("#SignInForPersonal").show(); 
                      }
              }
          else
              {
                  $("#member_menu_area").append(data);
              }
  
          total_m_group = $("#total_page_no").text();                     
          $("#total_m_group").remove(); // removing extra     
  
          movie_shown = $("#movie_shown").text();
          $("#movie_shown").remove(); // removing extra
  
      }, 
      complete: function(){                       
          $(window).on("scroll",function(){   
              var closeToBottom = ($(window).scrollTop() + $(window).height() &gt; $(document).height() - 500);
              var AtBottom = ($(window).scrollTop() + $(window).height() == $(document).height());            
              if (closeToBottom || AtBottom)  
                  {       
                      if( total_m_group != 0 )
                          {
                              if( group_no &lt; total_m_group )
                                  {   
                                      group_no++;
                                      IndexFeederLoader(group_no,total_m_group,movie_shown); // group_no is not changing
                                  }
                          }   
                      else
                          {
                              group_no = 0;
                          }
                  }   
          });
      },              
      error:function (xhr, ajaxOptions, thrownError){                
          alert(thrownError);
      }
  });             
  </code></pre>
  
  <p>}</p>
  
  <p>Now the problem. If I do not switch between public and personal, everything goes well and I get records in order of group_no set. But when I select personal and then come back to private, it does not work giving feeds from start but from where it has left. It seems like <code>group_no</code>is not changing.</p>
  
  <p>Thanks for reading. It would be great if anyone can help me pls.</p>