代码实例ajax实现点击加载更多数据图片_javascript技巧_脚本之家

点击越来越多图片,加载2条数据,当数码加载完了,就显得 “未有更加多了”

正文给大家介绍ajax怎样贯彻点击加载越多多少图片效果的,有早晚的参照他事他说加以考查价值,有亟待的爱侣能够参照一下,希望对你们全数助于。

[ { "img":"img/sina.jpg","title":"百度音乐1"}, { "img":"img/tengxu.jpg","title":"百度音乐2"}, { "img":"img/sina.jpg","title":"百度音乐3"}, { "img":"img/tengxu.jpg","title":"百度音乐4"}, { "img":"img/tengxu.jpg","title":"百度音乐5"}, { "img":"img/sina.jpg","title":"百度音乐6"}, { "img":"img/tengxu.jpg","title":"百度音乐7"}, { "img":"img/sina.jpg","title":"百度音乐8"}, { "img":"img/tengxu.jpg","title":"百度音乐9"}, { "img":"img/sina.jpg","title":"百度音乐10"}, { "img":"img/tengxu.jpg","title":"百度音乐11"}, { "img":"img/sina.jpg","title":"百度音乐12"}, { "img":"img/tengxu.jpg","title":"百度音乐13"}, { "img":"img/sina.jpg","title":"百度音乐14"}, { "img":"img/tengxu.jpg","title":"百度音乐15"}]
  ajax点击加载更多数据--博客园--勇淘未来   *{padding:0;margin:0;} .box {margin: 100px auto;width: 550px;} ul li {width:550px;list-style: none;} ul li span{text-align:center;display:block;} .clear {clear: both;} .load {text-align: center;display: none;margin-top:50px;color:#ccc;} .end{display:none;color:#ccc;}       加载中...  查看更多图片 没有更多了    var num = 0; var start = 0; var size = 2; $.ajax({ url: "dataNews.json", type: "get", success: function{ var str = ""; for{ str += "<li><img src="%20+%20res[i].img%20+%20"><span>"+ res[i].title +"</span></li>"; } $.append; }, error:function(){ console.log $.click{ $; setTimeout{ $; num++; console.log; start = num * size; $.ajax({ url:"dataNews.json", type:"get", success:function{ var sum = res.length; if { size = sum - start; $.css; $.css; } var str = ""; for(var i = start;i< { str += "<li><img src="%20+%20res[i].img%20+%20"><span>"+ res[i].title +"</span></li>"; } console.log; $; } }); },300) } ) 

代码实例ajax实现点击加载更多数据图片_javascript技巧_脚本之家。地点测量试验dataNews.json文件:

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图