Last active
July 26, 2016 14:47
-
-
Save alfredoem/5cbb08f325d92d5cf3f03780fbe28983 to your computer and use it in GitHub Desktop.
Laravel - Pagination with jQuery.ajax
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 characters
$(document).on('click', '.pagination a', function (e) { | |
$('.pagination').find('li').removeClass('active disabled'); | |
$(this).parent().addClass('active'); | |
let page = $(this).attr('href').split('page=')[1]; | |
let request = $.ajax({url : 'todo?page=' + page, dataType: 'json'}); | |
request.done(function (res) { | |
// handle res | |
}).fail(function () { | |
alert('Posts could not be loaded.'); | |
}); | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment