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

3
  • How do I call the same ajax call while data.next to null what does this mean ? Commented Oct 8, 2020 at 8: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 Commented Oct 8, 2020 at 8:13
  • stackoverflow.com/questions/25434813/… .... \ Commented Oct 8, 2020 at 8:26

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.