如何在
的加载更多按钮功能中包含json数据 var index = 1;
$(document).on("pagecreate", "#page1", function(){
$("#btnAdd").on("click", function(){
var allItems = '';
for (var i = 0; i < 100; i++) {
allItems += '<li><a href="javascript:showDetails(' + (index + i) + ')" >item number ' + (index + i) + '</a></li>';
}
index += 100;
$("#ListTemp").empty().append(allItems).listview("refresh");
var element = $("#ListTemp li").detach();
$("#ListDspQry").append(element);
});
});
我的json网址是:http://www.beritanisma.com/category/superlawak/?json=get_category_posts
已经尝试了几天,但最终没有显示任何结果,请帮助我主人,谢谢..
答案 0 :(得分:1)
var index = 0;
$(document).on("pagecreate", "#page1", function(){
$("#btnAdd").on("click", function(){
var url = "http://www.beritanisma.com/category/superlawak/?json=get_category_posts"
$.getJSON(url, function(data){
var allItems = '';
for (var i = 0; i < data.posts.length; i++) {
console.log(data.posts[i].url);
allItems += '<li><a href="javascript:showDetails(' + (index + i) + ')" >'+data.posts[i].url+'' + (index + i) + '</a></li>';
}
index += 100;
$("#ListTemp").empty().append(allItems).listview("refresh");
var element = $("#ListTemp li").detach();
$("#ListDspQry").append(element);
});
});
});