【发布时间】:2015-03-29 01:14:21
【问题描述】:
我正在开发一个应用程序,使用cordova 作为构建应用程序的平台,并使用作为后端安装的 JSON API 插件的 wordpress。 我编写了这两个函数来从我的网站上抓取帖子,然后在 jquery mobile 和 cordova 完全加载时将其显示给用户。
// App Logic
function init()
{
getData(1);
}
function getData(pageNumber) {
$.getJSON('http://blabla.com/wordpress/?json=get_recent_posts&page='+pageNumber, function(data) {
posts = data.posts;
$.each(posts, function(index, post) {
id = post.id;
title = post.title;
thumb = post.thumbnail;
comments = post.comment_count;
author = post.author['name'];
$('#posts_list').append('<a href="post.html?id='+id+'" data-ajax="false"><div class="single-post">'
+'<div class="img"><img src="'+thumb+'" class="lazy" title="" /></div>'
+'<div class="info">'
+'<div class="title">'+title+'</div>'
+'<div class="stats"><span class="author">'+author+'</span> <span class="comments">'+comments+' comments</span></div>'
+'</div>'
+'</div></a>');
});
});
}
我希望当用户在底部页面滚动时,代码会加载页面 2 的更多内容,直到帖子完全加载。 PS:这是服务器端输出的示例(JSON):
<!-- http://blabla.com/?json=get_recent_posts&page=1-->
{"status":"ok","count":10,"count_total":2039,"pages":204,"posts":[{.....}] }
【问题讨论】:
标签: jquery wordpress cordova jquery-mobile