我创建了这样一个模型,并收集:获取数据奇怪的参数
var TestModel = Backbone.Model.extend({
initialize: function() {
},
defaults: {
'id': null,
'title': '',
'description': ''
}
});
TestCollection = Backbone.Collection.extend({
model: TestModel,
url: function() {
return 'Test/GetAll';
},
});
然后我有一个观点我尝试加载这样的:
var testCollection = new TestCollection();
var testListView = new TestListView({ collection: testCollection });
testCollection.fetch();
但创建一个请求,如: Test/GetAll?_=1349272902901
失败。你们中的任何人都知道为什么它会将这个类似id的参数附加到请求中吗?
定义 '失败'。请求似乎被正确创建('_'部分被添加以防止缓存,我想),也许它的定义在第一个地方是不正确的? – raina77ow
问题不在于Backbone,而在于您的API。如果您完全按照描述访问网址,它会返回什么内容?像@ raina77ow提到的那样,参数被添加来防止缓存,并且不应该影响你的响应。如果您访问Test/GetAll和Test/GetAll?_ = 1349272902901,您仍应该从API /服务器获得相同的响应。 – TYRONEMICHAEL