向下滚动时在datalist中加载更多项目? [英] Load more items in datalist when scroll down ?
本文介绍了向下滚动时在datalist中加载更多项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在我的网站上制作滚动功能,当我向下滚动(如Facebook)时,会向数据列表中加载更多项目。这里是我的代码:
Hi all ,
I am making a scroll feature in my website that loads more items into the datalist when i scroll down (like Facebook).And here is my code :
<script type="text/javascript">
$(document).ready(function() {
function lastPostFunc() {
$('#divPostsLoader').html('<img src="images/bigLoader.gif">');
//send a query to server side to present new content
$.ajax({
type: "POST",
url: "Articles.aspx/ItemsGet",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
if (data != "") {
$('.divLoadData:last').after(data.d);
}
$('#divPostsLoader').empty();
}
})
};
//When scroll down, the scroller is at the bottom with the function below and fire the lastPostFunc function
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
lastPostFunc();
}
});
});
</script>
数据主义者与某个对象绑定数据源,我获取所有项目。所以在ItemsGet网页方法中,如何指定开头显示的项目数,然后向下滚动时增加此数字?
提前谢谢。
The datalist is bounded to an object datasource that is getting all the items.So in the ItemsGet web method,how can i specify the number of items displayed at the beginning,and then when scroll down increase this number ?
Thanks in advance.
推荐答案
(document).ready(function(){
function lastPostFunc(){
(document).ready(function() { function lastPostFunc() {
('#divPostsLoader')。html('< img src = images / bigLoader.gif > ');
//向服务器端发送查询以显示新内容
('#divPostsLoader').html('<img src="images/bigLoader.gif">'); //send a query to server side to present new content
.ajax({
type:POST,
url :Articles.aspx / ItemsGet,
data:{},
contentType:application / json; charset = utf-8,
dataType:json,
成功:函数(数据){
if(data!=){
.ajax({ type: "POST", url: "Articles.aspx/ItemsGet", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) { if (data != "") {
这篇关于向下滚动时在datalist中加载更多项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文