链接标题分页 - Dribbble API

问题描述 投票:0回答:1

我正在使用 Dribbble API,但我不理解他们有关分页的文档:http://developer.dribbble.com/v1/#pagination

我尝试研究如何设置此设置,但我似乎找不到有关如何使用链接标头进行设置的信息。这是我现在使用的代码,它可以完美地提取 12 个最近的镜头,但我对分页感到困惑:

$(document).ready(function() {

var url = 'https://api.dribbble.com/v1/user/shots?per_page=12&access_token=*removed*';
var $content = $('#dribbble');

$.ajax({
    type: 'GET',
    url: url,
    dataType: 'jsonp',
    beforeSend: function() {
        $content.append('<div class="loading"><img src="./img/ajax-loader.gif" width="66" height="66" alt="Loading"></div>');
    },
    complete: function() {
        $('#loading').remove();
    },
    success: function(data) {
        var template = $('#dribbbleTpl').html();
        var html = Mustache.to_html(template, data);
        $('#dribbble').html(html).hide().fadeIn(400);
    },
    fail: function() {
        $content.append('<div class="error">Oops! Our Dribbble feed appears to be down.</div>');
    }
})

});

pagination dribbble-api
1个回答
1
投票

由于您请求 jsonp,API 应该返回标头元数据。此标头将包含您的链接数据。如果您在响应中没有看到标头,请尝试将

&callback=foo
添加到您的端点 URL。

© www.soinside.com 2019 - 2024. All rights reserved.