<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style_scrollinf.css" />
</head>

<body>
<div id="mhead"><h2>Ajax Infinite scroll using jQuery - InfoTuts</h2></div>
<img id='loading' src='img/loading.gif'>
<div id="listarInforegAnoMesDia_full" cellspacing="0"></div>
<script>
var ajax_arry=[];
 var ajax_index =0;
 $(function(){	
	$('#loading').show();
	var parametros={"bus":"To","pen":"To","ent":"To","asi":"To","res":"To","ano":"To","mes":"To","dia":"To","page":"1"};
	$.ajax({
		data:parametros,
		url:'core/listarInforegAnoMesDia_full.php',
		type:'post',
		cache: false,
        success:  function (response) {
			$('#loading').hide();
        	$("#listarInforegAnoMesDia_full").html(response);
        }
	});

	$(window).scroll(function(){
		//alert(ajax_arry.length);
		 if(ajax_arry.length>0){
			 $('#loading').hide();
				 for(var i=0;i<ajax_arry.length;i++){
				 ajax_arry[i].abort();
			 }
		 }
		 var page = $('#listarInforegAnoMesDia_full').find('.nextpage').val();
		 var isload = $('#listarInforegAnoMesDia_full').find('.isload').val();
		//alert('page: '+page+'---isload: '+isload);
	   
	     if ((($(window).scrollTop()+document.documentElement.clientHeight)===$(document).height()) && isload==='true'){
			 //alert('Entroooooooooooo');
			 $('#loading').show();
			 var param = {"bus":"To","pen":"To","ent":"To","asi":"To","res":"To","ano":"To","mes":"To","dia":"To","page":page};
			 var ajaxreq = $.ajax({
				 url:"core/listarInforegAnoMesDia_full.php",
                 type:"POST",
                 data:param,
				 cache: false,
				 success: function(response){
					 $('#listarInforegAnoMesDia_full').find('.nextpage').remove();
					 $('#listarInforegAnoMesDia_full').find('.isload').remove();
					 $('#loading').hide();
					 $('#listarInforegAnoMesDia_full').append(response);
				 }
			 });
	   		ajax_arry[ajax_index++]= ajaxreq;
		 }
		 
		 if($(window).scrollTop() === $(document).height()) {
			 alert("bottom!");
   		 }
		 return false;
	});
});
</script>
</body>
</html>