1(function($){ 2 $('.js-loadmore-posts').click(function(){ 3 4 var button = $(this), 5 data = { 6 'action': 'loadmore', 7 'query': loadmore_posts_params.posts, // that's how we get params from wp_localize_script() function 8 'page' : loadmore_posts_params.current_page 9 }; 10 $.ajax({ 11 url : loadmore_posts_params.ajaxurl, // AJAX handler 12 data : data, 13 type : 'POST', 14 beforeSend : function ( xhr ) { 15 button.text('Loading...'); // change the button text, you can also add a preloader image 16 }, 17 success : function( data ){ 18 if( data ) { 19 button.text( 'More posts' ).before(data); // insert new posts 20 loadmore_posts_params.current_page++; 21 22 if ( loadmore_posts_params.current_page === loadmore_posts_params.max_page ) 23 button.remove(); // if last page, remove the button 24 25 // you can also fire the "post-load" event here if you use a plugin that requires it 26 // $( document.body ).trigger( 'post-load' ); 27 } else { 28 button.remove(); // if no data, remove the button as well 29 } 30 } 31 }); 32 }); 33})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.