Skip to content

Instantly share code, notes, and snippets.

@alfredoem
Last active July 26, 2016 14:47
Show Gist options
  • Save alfredoem/5cbb08f325d92d5cf3f03780fbe28983 to your computer and use it in GitHub Desktop.
Save alfredoem/5cbb08f325d92d5cf3f03780fbe28983 to your computer and use it in GitHub Desktop.
Laravel - Pagination with jQuery.ajax
$(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