简体   繁体   English

使用ajax .load加载动态URL?

[英]Loading dynamic url using ajax .load?

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. 默认情况下,将加载http://example.com/?page_id=1208&paged=1 ,因此,如果我单击“加载更多”按钮,则需要将新内容附加到页面中,而不是从页面1加载,每次单击“加载更多”按钮时,都从第2、3和4页加载。

How do I make a ajax call that will work with multiple urls? 如何进行可与多个URL一起使用的Ajax调用?

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. 我使用了jQuery ajax .load,但问题是nextLink变量不会被更新,因为它已经加载到js文件中。

var url = "http://example.com/?page_id=1208&paged="
var pageNum = 1;
var nextLink =url+pageNum;

 $('.content-'+ pageNum).load(nextLink + ' .each-block',
    function() {
        pageNum++;
    }
);

class eqals content1 类eqals content1

 $('.content-'+ pageNum).load(nextLink, function() {
        pageNum++;
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM