// source --> https://www.appcluesinfotech.com/wp-content/themes/wp_appcluesinfotech/assets/js/my_query.js?ver=6.1.1 jQuery(document).ready(function() { var win = jQuery(window); // Each time the user scrolls var data_scroll = 1; win.scroll(function() { // End of the document reached? if (jQuery(document).height() - win.height() == win.scrollTop()) { jQuery('#loading').show(); if(data_scroll == 1){ var data = { 'action': 'my_action', 'whatever': ajax_object.we_value // We pass php values differently! }; // We can also pass the url value separately from ajaxurl for front end AJAX implementations jQuery.post(ajax_object.ajax_url, data, function(response) { jQuery('#posts').append(response); jQuery('#loading').hide(); }); } // Uncomment this AJAX call to test it /* $.ajax({ url: 'get-post.php', dataType: 'html', success: function(html) { $('#posts').append(html); $('#loading').hide(); } }); */ console.log('123'); //jQuery('#loading').hide(); //$('#posts').append(randomPost()); //jQuery('#loading').hide(); } data_scroll = 5; }); });