Reputation: 1657
I have multiple pages that I need to load dynamically whenever a load more button is click
http://example.com/?page_id=1208&paged=1
http://example.com/?page_id=1208&paged=2
http://example.com/?page_id=1208&paged=3
http://example.com/?page_id=1208&paged=4
By default http://example.com/?page_id=1208&paged=1 will load up, so if I click on the load more button I need to append the new content into the page but instead of loading from page 1 I will need to load from page 2,3 and 4 every time I click on the load more button.
How do I make a ajax call that will work with multiple urls?
I used jQuery ajax .load but the problem is the nextLink variable will not be updated since it is already loaded in the js file.
var url = "http://example.com/?page_id=1208&paged="
var pageNum = 1;
var nextLink =url+pageNum;
$('.content-'+ pageNum).load(nextLink + ' .each-block',
function() {
pageNum++;
}
);
Upvotes: 0
Views: 162
Reputation: 14649
class eqals content1
$('.content-'+ pageNum).load(nextLink, function() {
pageNum++;
}
);
Upvotes: 1