【发布时间】:2015-10-16 06:50:24
【问题描述】:
如何将分页添加到我的 JSON 解析器代码中?
function appendPost(__, post) {
var title = $('<div/>')
.addClass('post_title')
.text(post.post_title);
var content = $('<div/>')
.addClass('post_content')
.text(post.post_content);
$('#test')
.append(title)
.append('<br/>')
.append(content);
}
function processResults(parsed_json) {
var posts = parsed_json.result || [];
$('#test').empty();
$.each(posts, appendPost);
}
jQuery(document).ready(function($) {
$.getJSON("https//website-API-json.com/string")
.then(processResults);
});
我一直在试图弄清楚,但似乎无法正确解决。
JSON 结果具有服务器分页,但我似乎无法获得更改/请求新结果页面的动态方式。
有什么想法吗?
这是 JSON 的输出
{
"respond":1,
"paging":{
"stillmore":0,
"perpage":10,
"callpage":1,
"next":2,
"previous":0,
"pages":1,
"result":"1"
},
"message":"",
"result":[]
}
【问题讨论】: