1

我正在尝试加载页面的片段,更准确地说#index-section,但是如果我为页面的 URL 使用变量,它会加载整个页面。

nextPage = 2;
nextURL = '/page/' + nextPage;
console.log(nextURL); // returns /page/2
$('#index-section').load(nextURL + '#index-section'); // loads entire page

如果我直接使用 URL,没有变量,效果很好

$('#index-section').load('/page/2 #index-section');

我究竟做错了什么 ?

4

1 回答 1

2

您必须在 url 和选择器之间放置一个空格

$('#index-section').load(nextURL + ' #index-section');
//                                  ^
于 2013-11-11T15:35:32.743 回答