开发者

How to setup parameters in a Backbone.Model to handle .fetch() function?

开发者 https://www.devze.com 2023-03-07 17:10 出处:网络
I have a question regarding the fetch function of Backbone. I\'ve read from the Backbone documentation that i开发者_开发问答t \"Refreshes the model\'s state from the server.\" but on the server I don

I have a question regarding the fetch function of Backbone. I've read from the Backbone documentation that i开发者_开发问答t "Refreshes the model's state from the server." but on the server I don't have the same model, moreover how do I give the url connection with the server? Is it like:

var model = new Backbone.Model({
some: "data",
});

model.url = "www.some.url";

setInterval(function(){
model.fetch();
}, 10000);

And this would fetch from some.url every 10 seconds some JSON I guess, right? Where exactly do I receive & process this JSON?

Thanks a lot

Masiar


I found out by myself a simple solution:

setInterval(function(){
    model.fetch({
        success: function(){
            //do something
        }
    });
 }, 10000);

Hope this is going to be helpful for someone else!

Cheers, Masiar

0

精彩评论

暂无评论...
验证码 换一张
取 消