【问题标题】:jQuery Pagination from getJSON Results (no plugin)来自 getJSON 结果的 jQuery 分页(无插件)
【发布时间】:2013-01-08 02:00:24
【问题描述】:

任何能够帮助我解决以下问题的人:

以下代码是我的脚本的缩短版本,它可以运行并显示大量结果。但是我想为它做某种分页,不知道从哪里开始:例如:显示 10 个结果和下一个链接...单击 n ext 显示下一个 10,然后是 prev 链接等....

希望有人能帮我解决这个问题

$.getJSON(Url).done(function(data) {
  // Console log the returned data (I used for testing to quickly know what data i wanted to display later)

  // Loop through the results
  $.each(data.photos.photo, function(i, data) {
    $(".results").append($("<a>").attr("href", PhotoUrl).attr("target", "_blank").append($("<img>").attr("src", ThumbUrl)));
  });
});

【问题讨论】:

    标签: jquery json pagination getjson


    【解决方案1】:

    通常您在查询中使用 LIMIT 子句并将 START 和 END 值保存在脚本中。然后,当用户单击下一个或上一个按钮时,您只需使用 LIMIT 子句的参数调用查询。

    【讨论】:

    • 我没有从数据库中获取它,它来自一个 API,在这种情况下是 Flickr 的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 2010-12-17
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 2011-12-18
    相关资源
    最近更新 更多