Php 为什么我的加载滚动不工作,是ajax调用吗?

Php 为什么我的加载滚动不工作,是ajax调用吗?,php,ajax,jquery-ui,Php,Ajax,Jquery Ui,计划是在一页内添加一个带有加载滚动条的滚动条。2个问题:我的加载滚动不工作&我不确定是否应该使用iframe来实现加载滚动。主要是因为我在div中有一个jQuery可排序、可拖放,并且不确定是否可以拖出iframe。如有任何意见,将不胜感激 $(#win).scroll(function(){ //replaced window with #win, which is the id of the div containg database info if($(this)[0].scrol

计划是在一页内添加一个带有加载滚动条的滚动条。2个问题:我的加载滚动不工作&我不确定是否应该使用iframe来实现加载滚动。主要是因为我在div中有一个jQuery可排序、可拖放,并且不确定是否可以拖出iframe。如有任何意见,将不胜感激

$(#win).scroll(function(){
//replaced window with #win, which is the id of the div containg database info
    if($(this)[0].scrollTop() == $(this)[0].height()- $(this).height()){

        //everytime we scroll we have this function activated
    //if statement is saying if we're at the bottom of the page
        //$('div#text').hide();
        $('div#loadMoreComments').show();
    //.show is showing the div above which has the loading animation

    $.ajax({
    url: "loadem.php?lastComment="+ $(".postedComment:last").attr("id"),
     //using get variable to say last comment is equal to + posted 
    //comment which is the last comment that's displayed &
    //that last comment has an id 
    success: function(html){
        if (html){
            $("#postedComment").append(html);
            //if we are at the bottom we will add comments to the page
            //and hide the animation
            $('div#loadMoreComments').hide();
            //$('div#text').show();


        }else{
            $('div#loadMoreComments').replaceWith("<div class='box'><center>Finished Loading</center></div>");
        //if theres no more to scroll then the finished loading will show
        }
    }
    });

    }
});
$(#win).滚动(函数(){
//将窗口替换为#win,它是包含数据库信息的div的id
如果($(此)[0].scrollTop()==$(此)[0].height()-$(此).height()){
//每次滚动都会激活此功能
//if语句表示我们是否在页面底部
//$('div#text').hide();
$('div#loadMoreComments').show();
//.show正在显示上面有加载动画的div
$.ajax({
url:“loadem.php?lastComment=“+$(“.postedComment:last”).attr(“id”),
//使用get变量表示最后一条评论等于+post
//注释显示的最后一条注释&
//最后一条评论有一个id
成功:函数(html){
如果(html){
$(“#postedComment”).append(html);
//如果我们在底部,我们会在页面上添加评论
//并隐藏动画
$('div#loadMoreComments').hide();
//$('div#text').show();
}否则{
$('div#loadMoreComments')。替换为(“已完成加载”);
//如果不再滚动,则显示已完成加载
}
}
});
}
});
此代码将用于页面的连续分页。据我所知,它不会对可排序、可删除的元素产生影响,因为您说过它的分页div已经覆盖了所有子元素


希望这会有所帮助。

@webarto谢谢,但这对我没有帮助。我想如果我想让整个页面成为一个加载滚动条的话,那就行了。我只想在我的div信息有一个加载滚动。有什么建议吗?是的,明白了!!如果您需要在特定的div id replaceid中进行无限滚动,那么遵循此链接可能会对您和您正在寻找的人有所帮助。。。[链接]如果我遗漏了什么,请告诉我第一个链接没有将我带到任何加载滚动区域,而且他们没有搜索栏,因此我无法搜索。第二个链接已失效抱歉,第一个链接已重定向到主页,但这是正在工作的第二个链接第一个链接也在工作,请参见此…很抱歉,给您带来不便,因为我是此网站的新手。在同一天,你可以随意问任何问题。
if((jQuery(window).scrollTop()) > (jQuery(document).height() - jQuery(window).height()))
{
 ...... YOUR CODE IS HERE.....
}