AJAX 请求下一页/上一页的帮助
如何使用 AJAX 获取下一页/上一页。
如何在浏览器中调用:
page.php?page=1-1
或者
page.php?page=1
返回的只是文本。
应以这种格式加载页面:
1-1 或者 1
当用户单击下一页/上一页按钮时,如何将该页码传递给 ajax 调用并显示结果。
另外,如何跟踪用户当前正在查看的页面? 我如何设置页面的最大最小值,比如我有 100 个页面,不要调用第 101 页
HTML
<input id="loadPages" name="loadPages" type="button" value="Next" />
<input id="loadPages" name="loadPages" type="button" value="Previous" />
<div id="displayResults" name="displayResults">
</div>
JS(这不起作用)
$("#loadPages").click(function(){
$.ajax({
url: 'page.php',
data:{'page': '1-1'},
error : function (){ alert('Error'); },
success: function (returnData) {
alert(returnData);
$('#displayResults').append(returnData);
}
});
});
How do I use AJAX to get the Next/Previous Page(s).
How to call in a browser:
page.php?page=1-1
or
page.php?page=1
The return is just text.
Should load pages in this format:
1-1
or
1
When the user clicks the next/previous page button(s) how do I pass that page number to the ajax call and display the results.
Also how do I keep track of what page the user is currently viewing?
And how do I put a max min for pages, like I have 100 pages don't make call for page 101
HTML
<input id="loadPages" name="loadPages" type="button" value="Next" />
<input id="loadPages" name="loadPages" type="button" value="Previous" />
<div id="displayResults" name="displayResults">
</div>
JS (This is not working)
$("#loadPages").click(function(){
$.ajax({
url: 'page.php',
data:{'page': '1-1'},
error : function (){ alert('Error'); },
success: function (returnData) {
alert(returnData);
$('#displayResults').append(returnData);
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样的事情...保留一个名为
currentPage
的全局变量,并相应地调整页码。现场演示 http://jsfiddle.net/Jaybles/MawSB/
< strong>HTML
JS
然后你的php页面就可以访问
$_REQUEST['page'];
并相应地返回数据。Try something like this... Keep a global variable called
currentPage
and simply adjust the page number accordingly.LIVE DEMO http://jsfiddle.net/Jaybles/MawSB/
HTML
JS
Then your php page can access
$_REQUEST['page'];
and return data accordingly.