0

バックボーンフェッチの問題を解決しようとしています。「Failed to fetch!」というメッセージが表示されます。私のコンソールで。

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