我正在尝试解决骨干提取的问题。我得到'无法取得!'在我的控制台中。
我认为这不是与同一原始政策相关的问题,因为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!');
}
});