How to use ajax pagination in cakephp


Posted on 12 Apr 16 by Vickey

Cakephp provide inbuilt pagination. By using Paginator component we can apply pagination very easily. For example

public $components = array('Paginator');

public function index() {

	$this->Blog->recursive = 0;
	$this->set('users', $this->Paginator->paginate());


and in view

<div class="pagination">

echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));


But when we click on any page number the whole page will be refresh again with new records.  If you dont want to reload page you can fetch all record by using ajax. There is no need to change any code. For load pages by ajax add the below javascript code.

   $(".pagination a").click(function(){
         return false;


If this post help you reduce time to develop, you can help me to maintain this website :)