简体   繁体   中英

codeigniter: pagination in ajax page

I have notification list. Onclick view notification. I get all the notification info list. This is done by ajax call by passing notification id.

Now, I want to use pagination to display notification info.

Here is the problem: I am using default pagination class provided by codeigniter. I am setting base_url like,

base_url().'notification'

The real page is: notification/display_notification_info . (This display notification info is done by ajax).

When I change base url for pagination then I will miss notification Id. And when I keep same base url as displayed above then I am not getting correct page link.

What should I do in this case to keep notification id (variable) through out pagination.

Can I pass that variable through pagination create link. But, I can't find way to pass external variable from those create links.

Thanks.

What you can do is just get rid of the pagination class (since you are using ajax to paginate) and keep track of your offset / limit (for database).

Just use a variable to keep track of offset, and do an ajax request for new data set (limit stays the same and returns you say 10 records, your offset is then 10, then 20, 30, etc;).

Pagination for CI only helps if you use the view, it creates the links for you automatically, otherwise you would just go through the limit + offset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM