Skip to content
Advertisement

How to paginate with ajax using pager library in codeigniter 4

hellow everyone, I am creating ajax pagination with CI4 Pager library, but I found it difficult to catch id of the pagination counter. instead of using full URI path like “localhost/view-user/?page=1”, I want to be able to catch only “1” so I can pass it using javascript as post variable that will allow me to path inside paginate method as parameter like this( paginate(5, ‘test’, $page = 1)). How can I do that and make it work with ajax?

//html pagination links

JavaScript

// my controller

JavaScript

my js

JavaScript

Advertisement

Answer

I decided to add additional methods inside Codeigniter4frameworksystemPagerPageRenderer.php. So it will asstist when want to set data attribute inside Pagination anchor tag ie.

JavaScript

// pageRenderer.php

JavaScript

PagerViewsdefault_full.php

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement