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条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试