Pagination for Ajax methods

I have an Ajax method in CakePHP-3.4 within that I am using paginate for the custom query which is returning proper results. Now I am trying to set the pagination in the view for the ajax response. How to do that?

You can look at this sandbox example

or what I done as a quick hack, wrap everything non paginated in a if

<?php if (!$this->request->is('ajax')): ?>
.... // headers an options
<?php
endif;
foreach ($models as $model): ?>
    // Ajax content, list
<?php endforeach; ?>
// more content, like a footer

And then replace the “inner content” div with the next ajax call

Thanks, But I got a work around and fix that.

Hi,
Can you give me ajax_pagination source code or guide ajax_pagination ?
myemail: anhtu032@gmail.com.
Thanks.

I am unable to share the exact code but I can help you what exactly I used. I used https://github.com/botmonster/jquery-bootpag and then fetched the page count in the response of the ajax method also reload the content where the pagination was in on('page' event of bootpag.

Thanks aavrug,

I did it but i dont use query bootpag, I use jquery and requestHandler of Cakephp.

Try to use bootpag because I got this easy for my situation and it is running smoothly with that.