所以不是$.post
如你所说的寻找$_GET['page']
所以你可以做这样的事情:
<script>
$(document).ready(function(e) {
var page_num = 1;
$('.nextpage').on('click',function(e){
e.preventDefault(); // stop the link from going anywhere
$.get('./page.php',
{
page: page_num // this is the same as $_GET['page']
},
function (data) {
$('#result').html(data);
page_num++;
}
);
});
$('.nextpage').click(); // emulate the click to get the first page
});
</script>
,并在你的身体是这样的:
<a href="/page.php?page=2" class="nextpage">Next page</a>
这是值得注意的是,在你的page.php
你不需要那样的表格,因为我看不到它会做很多事情
UPDATE
所以有操作上index.php
分页从page.php
你可以有page.php
返回一个隐藏的div称为.hidden_pagination
其全部内容一起。
<script>
$(document).ready(function(e) {
$('.pagination').on('click','a',function(e){
e.preventDefault(); // stop the link from going anywhere
var next_page = $(this).attr('data-id'); // get the next page from the link data-id attribute
$.get('./page.php',
{
page: next_page // this is the same as $_GET['page']
},
function (data) {
$('#result').html(data);
$('.pagination').html($('#result').children('.hidden_pagination').html()); // add the new pagination to the current pagination
}
);
});
$('.nextpage').click(); // emulate the click to get the first page
});
</script>
<div class="pagination">
<a href="#" class="nextpage" data-id="2">Next page</a>
</div>
<div id="result">
this will be replaced with the ajax response
</div>
是的,这确实是一个愚蠢的错误,但我想留在AT index.php并操纵page.php中的分页。也许我应该这样做
嗯,我看到,所以我会建议是在page.php返回一个隐藏的输入元素(div)的操纵分页..然后你可以更新你的index.php分页与新信息 - 我会更新我的答案,以反映这 – 2013-04-25 13:13:01
你确定这是正确的方法,因为