$(document).ready(function() { var win = $(window); win.scroll(function() { if ($(document).height() - win.height() - win.scrollTop() < 150) { var formData = $('#pagination form:last').serialize(); if (formData) { $('#pagination').html('
'); $.ajax({ type: "POST", url: './', data: formData, dataType: 'html', success: function(data) { var body = $(data); $('#pagination').remove(); $('#main_results').append('