"); action = "inactive"; } } }); } if(action == 'inactive') { action = 'active'; load_country_data(limit, start); } $(window).scroll(function(){ if($(window).scrollTop() + $(window).height() > $("#load_data").height() && action == 'inactive') { action = 'active'; start = start + limit; setTimeout(function(){ load_country_data(limit, start); }, 1000); } }); });