1jQuery(function($){ // use jQuery code inside this to avoid "$ is not defined" error 2 $('.loadmore').click(function(){ 3 var button = $(this), 4 data = { 5 'action': 'loadmore', 6 'query': loadmore_params.posts, // that's how we get params from wp_localize_script() function 7 'page' : loadmore_params.current_page, 8 'nonce': loadmore_params.nonce, 9 }; 10 // console.log(loadmore_params.posts); 11 $.ajax({ // you can also use $.post here 12 url : loadmore_params.ajaxurl, // AJAX handler 13 data : data, 14 type : 'POST', 15 beforeSend : function ( xhr ) { 16 button.addClass('animate'); // change the button text, you can also add a preloader image 17 }, 18 success : function( data ){ 19 if( data ) { 20 button.siblings('.load-posts-container').append(data); // insert new posts 21 loadmore_params.current_page++; 22 23 if ( loadmore_params.current_page == loadmore_params.max_page ) 24 button.remove(); 25 // if last page, remove the button 26 27 // you can also fire the "post-load" event here if you use a plugin that requires it 28 // $( document.body ).trigger( 'post-load' ); 29 } else { 30 button.remove(); // if no data, remove the button as well 31 } 32 } 33 }); 34 }); 35});
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.