0

I am having one url

url = someurl?limit=5

This will return the 5 elements the format is

"count": 290,
"next": "someurl?limit=5&offset=5",
"previous": null,
"status": true,
"result": []

What I need to implement a pagination

In initial load it need to be 5 and after scrolling the new datas are append to it

     $.ajax({
        dataType: "json",
        url: url,
        success: function(data) {
            ***********some stuffs for appending data in to html ****
      }

In this success data I am getting next url when I was calling data.next

How do I call the same ajax call while data.next to null

Anoop
  • 505
  • 8
  • 23
  • `How do I call the same ajax call while data.next to null` what does this mean ? – KcH Oct 08 '20 at 08:10
  • In a ajax call success it returnin data... In the data.next it having url for the next pagination .... For example in initial I am loading 0: 10 datas then the next url for 10:20 datas SO I need to append those 10:20 elements v – Anoop Oct 08 '20 at 08:13
  • https://stackoverflow.com/questions/25434813/simple-pagination-in-javascript .... \ – KcH Oct 08 '20 at 08:26

1 Answers1

0

here you need to add in start param that gets incremented as per your limit

/assuming you are getting your first data on page load increments start from 0 to 5 so you get limit 5,5 in your next records/

<script>
var lmt = 5;
var start = lmt;

fucntion paginate(){
strt = strt + lmt;
url = someurl?limit=lmt&start=strt;
}
</script>

using global javascript variables are not secure.

Jawwad Ahmed
  • 302
  • 1
  • 10