weixin_33749131 2015-12-11 05:54 采纳率: 0%
浏览 16

限制来自AJAX调用的结果

I want to limit the amount of results that are being returned from this AJAX call to 5. I think I could use .slice() to do this but I'm not exactly sure what way to go about it.

$(document).ready(function() {
  $.ajax({
    type: "GET",
    url: "myurl",
    dataType: "xml",
    cache: false,
    success: parsePopular
  });
});

function parsePopular(popular) {
  $(popular).find("item").each(function() {
    $("#popularArticles").append("<h1><p class='Bold'><a href='" + $(this).find("link").text() + "'>" + $(this).find("title").text() + "</a></p></h1>");
  });
}

Any ideas would be great.

Thanks.

  • 写回答

2条回答 默认 最新

  • Lotus@ 2015-12-11 05:56
    关注

    Slice and remove

    $(popular).find('item').slice(5).remove();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办