3

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.

Amin Eshaq
  • 4,034
  • 1
  • 17
  • 21
  • Looks like a cache-buster, but AFAIK Backbone doesn't add anything like this by default. Are you using any add-on libraries or anything like that? – nrabinowitz Oct 14 '11 at 00:03

1 Answers1

7

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 to fetch() (which gets passed to $.ajax()):

mydocument.fetch({ cache: true });

If that works but you don't want to do it every time, you could set it globally with jQuery.ajaxSetup().

Community
  • 1
  • 1
nrabinowitz
  • 55,314
  • 10
  • 149
  • 165