Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

pagination in javascript for API

ab1ab1 Member Posts: 1
I have an API which contains a JSON . The JSON looks like as shown below

{"oldestId":"1","latestId":"42","records":[{"id":"42","uid":"34","time":"1134314","email":"mwright@.com","fName":"Matt","lName":"Wright","level":"0","description":"User mwright@att.com logged in"},{"id":"41","uid":"34","time":"1134314","email":"mwright@.com","fName":"Matt","lName":"Wright","level":"0","description":"User mwright@att.com logged in"},{"id":"40","uid":"34","time":"1134314","email":"mwright@.com","fName":"Matt","lName":"Wright","level":"0","description":"User mwright@att.com logged in"},{"id":"39","uid":"34","time":"1134314","email":"mwright@.com","fName":"Matt","lName":"Wright","level":"0","description":"User mwright@att.com logged in"}]}

I call the API from database on server side by Xmlhttp request and then put the JSON as an object in Javascript . I display the result of JSON as a list of activity tasks row by row as shown below

mwright@.com , Matt Wright , User mwright@att.com logged in , Jan 2, 1970, 22:5:14

mwright@.com , Matt Wright , User mwright@att.com logged in , Jan 2, 1970, 22:5:14

mwright@.com , Matt Wright , User mwright@att.com logged in , Jan 2, 1970, 22:5:14

mwright@.com , Matt Wright , User mwright@att.com logged in , Jan 2, 1970, 22:5:14

I would like to display this result with pagination in javascript as there a lot of activity tasks and each page has to display 15 recent activity tasks . I tried jquery but it did not work . I have to display the above shown result with first,last, next and previous pagination options . The result is dynamic and the result changes daily and I have to show 15 recent activity tasks starting with the most recent activity task on one webpage using latestId in JSON and less recent activity task using oldestId in JSON and also I need to set limit for total recent activity tasks to 40 . Can anyone tell me the javascript functions needed for pagination which can be used with API . I have written javascript for generating above result using document.write already and it works fine . I only need to do pagination . I cannot put the above results in datatable because one of my JSON value that is time is in unix time format and it needs to be converted into local time so the result looks like as shown above Can anyone tell me how to set the above result so that the page can be paginated with first,last, next and previous pagination options . I am really stuck . If anyone needs more details please ask me
Any help with examples would be appreciated
Thanks in advance


Sign In or Register to comment.