0

我正在尝试解决主干提取问题。我收到“无法获取!” 在我的控制台中。

我认为这不是与同源策略相关的问题,因为 JSON 是从服务器返回的,并且根据JSONLint是有效的

[{"name":"Spanish A1"},{"name":"Spanish A2"}]

要点代码:https ://gist.github.com/KonradMasalski/bfaac7d481d890ca5c54

更新 - 代码

var Fishe = {};

Fishe.Deck = Backbone.Model.extend({
    initialize: function () {
        alert("Welcome to this world");
    }
});

Fishe.DeckCollection = Backbone.Collection.extend({
    model: Fishe.Deck,
    url: 'http://fishes.localhost/deck.json',
    sync: function (method, model, options) {
        console.log('syncing');
        var params = _.extend({
            type: 'GET',
            dataType: 'jsonp',
            url: this.url,
            success: function (data, textStatus, jqXHR) {
                console.log(data)
            },
            error: function (jqXHR, textStatus, errorThrown) {
                this.model.set($.parseJSON(jqXHR.responseText));
            }
        }, options);

        return $.ajax(params).done(function () {
            console.log('finished')
        });
    }
});


Fishe.data = {};
Fishe.data.decks = new Fishe.DeckCollection();

Fishe.data.decks.fetch({
    success: function () {
        console.log(Fishe.data.decks.toJSON());
    },
    error: function () {
        console.log('Failed to fetch!');
    }
});
4

0 回答 0