You can use the event .scroll()
in his window
, sort of like this:
$(window).scroll(function() {
if( $(window).scrollTop() + $(window).height() == $(document).height() ) {
var url = document.URL;
var pageNumber = url.split('=')[1];
var newUrl = "http://localhost/sistema_importa/base_importat.php?pagina=" + pageNumber;
$(location).attr('href', newUrl);
}
});
If you want the page to be reloaded when the user gets close to the end, use this:
$(window).scroll(function() {
if( $(window).scrollTop() + $(window).height() > $(document).height() - 100 ) {
var url = document.URL;
var pageNumber = url.split('=')[1] + 1;
var newUrl = "http://localhost/sistema_importa/base_importat.php?pagina=" + pageNumber;
$(location).attr('href', newUrl);
}
});
* Where the 100
condition represents the size in pixels relative to the bottom of the page, you can change to the number you want.
But I do not recommend this solution, I advise you to use some plugin Infinite Scroll/Lazy Loading
.
Thank you @Eduardo-silva I modified your idea
<script>
 $(document).ready(function() {
 //requisição ajax para selecionar postagens
 var url = document.URL;
 var pageNumber = url.split('=')[1];
 var numeroNovo = parseInt(pageNumber)-1;
 var newUrl = "http://localhost/sistema_importa/base_importat2.php?pagina=" + numeroNovo;

 $(location).attr('href', newUrl);
 }); // fim document ready
 </script>
– joao_coelho