dongmaoxi0477 2011-10-20 09:40
浏览 35
已采纳

用ajax分页

I've build an application (with PHP, Codeigniter and jQuery) that uses ajax for pagination, similar to how Twitter made it back in the day (clicking a button to load in more data).

It's all quite well, but there are a few issues however.

When there are no more posts left to load in, I want the "load-more"-button to be removed. However, right now I can only check if there are any posts left when I click the button, and the script returns null.

This is how it is now: Let's say that there are 14 posts in the database. 5 is loaded per default.

1 - click load-more, 5 more posts are loaded. 4 remain.

2 - click load-more, the remaining 4 posts are loaded.

3 - click load-more, no more remaining posts, button disappears

But I want to get rid of step 3, the application should "be aware" of that there are no more posts left to render at step 2.

I am sure there are a simple way that I haven't thought if yet...

  • 写回答

5条回答 默认 最新

  • douwu7563 2011-10-20 10:53
    关注

    simple. select 6 posts instead of 5 and display only 5.If no of posts less than 6 dont display more button.

    if ($num_rows < 6){
      //remove more button
    } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)