From the course: Ajax with PHP: Add Dynamic Content to Websites

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use a data attribute

Use a data attribute

From the course: Ajax with PHP: Add Dynamic Content to Websites

Start my 1-month free trial

Use a data attribute

- [Instructor] In the last movie, we learned to append Ajax results to a div on the page. But, we were getting results for page 1 back every time. In this movie, we will learn to send different page numbers in our request, and then learn how to keep track of the current page by using a data attribute. So, we've seen how we make our request, always using Page 1. That's just a static value. What we want to do now, is we want to be able to have our new page variable be set here. So, page is what we're going to be working with, let's actually call it "next_page", and that's the value we want to come up with. We want to figure out how do we determine what is next_page? So, let's first figure out how we determine what the current page is, and then we'll be able to figure out our next_page from there. Because that will be page + 1. So, the current page could be a value that we just simply kept track of. We could start out with a value of 1, and then every time we could increment that value…

Contents