-
-
Save wisnust/f95e04df7880dba9bd71cadf932e3884 to your computer and use it in GitHub Desktop.
Revisions
-
allenbell created this gist
Feb 10, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ jQuery(document).ready(function($){ $(document).on( 'click touchstart', '#pagination a', function( event ) { // Fade out the old content for a smooth transition $('#bike-features-inner').fadeOut(); // The pagination button you clicked will pass the page number back to the callback function var page = $(this).attr('href'); // This will pass the post ID back to the callback function var bikeID = $(this).closest('#pagination').find('#bike-id').attr('data-bike-id'); event.preventDefault(); $.ajax({ url: ajaxpagination.ajaxurl, type: 'post', data: { action: 'dl_bike_features', // the name of the function in your php file page: page, // access in php function via $_POST['page'] bikeID: bikeID // access in php function via $_POST['bikeID'] }, success: function( result ) { // Replace the content of the container div w/ the output from dl_bikeFeatures() $('#bike-features-inner').html(result); // fade in this content for a smooth transition $('#bike-features-inner').fadeIn(); }, error: function(MLHttpRequest, textStatus, errorThrown){ alert('Sorry, something went wrong. Please try again.'); } }) }) });