Page 1 of 5

Pagination JSON

Posted: Fri Mar 14, 2014 2:21 pm
by Andrew Ashirbekov

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! :)


Pagination JSON

Posted: Fri Mar 14, 2014 4:03 pm
by Nikita

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".


Pagination JSON

Posted: Fri Mar 14, 2014 4:25 pm
by Andrew Ashirbekov

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


Pagination JSON

Posted: Fri Mar 14, 2014 5:05 pm
by Nikita

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.


Pagination JSON

Posted: Fri Mar 14, 2014 5:21 pm
by Andrew Ashirbekov

Does not work. or I did wrong


Pagination JSON

Posted: Fri Mar 14, 2014 5:21 pm
by Andrew Ashirbekov

Does not work. or I did wrong

Image

Image


Pagination JSON

Posted: Fri Mar 14, 2014 5:55 pm
by Nikita

Hi,

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


Pagination JSON

Posted: Fri Mar 14, 2014 6:07 pm
by Andrew Ashirbekov

Pagination JSON

Posted: Fri Mar 14, 2014 6:08 pm
by Andrew Ashirbekov

does not work: (


Pagination JSON

Posted: Fri Mar 14, 2014 6:12 pm
by Andrew Ashirbekov

Button does not work