Laravel jQuery pagination

Submitted by haruncpi - 4 years ago

First, add the jquery library in your template then write jQuery code for pagination. https://bit.ly/2EVAMO1

$(function(){
    function getData(page){
		if(!page) page=1;

		$.get('{{url('/')}}/post-data?page='+page)
			.success(function(data){
				$('#post').html(data)
			})
	}

	getData();

	$(document).on('click', '.pagination a', function(e){
	  e.preventDefault(); 
	  var page = $(this).attr('href').split('page=')[1];
	  getData(page);
	});
})

//more detail https://bit.ly/2EVAMO1