Backbone Model Fetch() 正在向 url 添加额外的参数
我已经为此研究了整整一个小时,我有一种感觉,这可能很简单。我正在使用下面的代码使用backbone.js 进行基本模型获取。
var Document = Backbone.Model.extend({
urlRoot: "/Package/Documents/GetDocumentById/"
});
mydocument = new Document({id: "3978204"});
mydocument.fetch()
我希望上面的代码能够调用以下 url,
localhost:3000/Package/Documents/GetDocumentById/3978204
但它却向查询添加了一个额外的参数,这会破坏我的方法。
localhost:3000/Package/Documents/GetDocumentById/3978204?_=1318548585841
我不知道如何 ?_=1318548585841
摆脱额外的参数。
任何帮助将不胜感激。
I've been going at this for a solid hour, and I have a feeling it might be something simple. I'm doing a basic model fetch with backbone.js with the code below.
var Document = Backbone.Model.extend({
urlRoot: "/Package/Documents/GetDocumentById/"
});
mydocument = new Document({id: "3978204"});
mydocument.fetch()
I would expect the above code to make a call to the following url
localhost:3000/Package/Documents/GetDocumentById/3978204
But instead it is adding an extra parameter to the query which is blowing up my method.
localhost:3000/Package/Documents/GetDocumentById/3978204?_=1318548585841
I have no idea how ?_=1318548585841
get rid of the extra parameter.
Any help would be apperciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此相关问题。这是由
jQuery.ajax()
添加的缓存破坏器,Backbone 在后台使用它。我相信您可以通过将
cache:true
作为选项传递给fetch()
(它被传递给$.ajax()
)来删除它:如果这有效,但您不想每次都这样做,您可以使用 jQuery 进行全局设置.ajaxSetup()。
Take a look at this related question. This is a cache-buster added by
jQuery.ajax()
, which Backbone uses in the background.I believe you can remove this by passing
cache:true
as an option tofetch()
(which gets passed to$.ajax()
):If that works but you don't want to do it every time, you could set it globally with jQuery.ajaxSetup().