Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

Hello! I've tried everything, I can not find a solution.
Need to do pagination through API WordPress
https://public-api.wordpress.com/rest...

URL: https://public-api.wordpress.com/rest...
Request: page
Image

How can I do to scroll through? Or via a button?

Sorry for my english! :)

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Pagination JSON

Hello,

You do it right. Also, you should add parameter "number" (it is at the link that you provided)
If you want to make the button "next", then you should use the same service, just pass the next value to parameter "page".

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

How to make a button "next" with the parameter "page" +1?
The parameter "number" I ask manually, this amount of records per page.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Pagination JSON

Hi,

You should save value of page in localStorage and on button click just increment this value:

var page = parseInt(localStorage.getItem("page"));
localStorage.setItem("page", page + 1);

You should invoke the service after this.

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

Does not work. or I did wrong

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

Does not work. or I did wrong

Image

Image

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Pagination JSON

Hi,

You do it right. You should set an initial value for this variable. For example on "load" event:
localStorage.setItem("page", "1");

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

does not work: (

Andrew Ashirbekov
Posts: 0
Joined: Fri Mar 14, 2014 2:21 pm

Pagination JSON

Button does not work

Return to “Issues”