1

我想使用 RequireJS 从服务器获取 JSON 格式的数据。我从不同来源请求数据,然后在回调中显示它。像这样:

require(
  ['text!/api/services/', 'text!/api/categories/1/'],
  function(services_json, category_json) {
    var services = $.parseJSON(services_json);
    var category = $.parseJSON(category_json);
    // displaying services and category.
  }
);

我的问题是有时我需要重新加载一些对象(如果它们已更改),但 RequireJS 不会第二次请求它,因为它不知道数据已更改。是否可以强制它重新加载一些数据?或从“缓存”中删除这些数据?

4

1 回答 1

0

Pulling in JSON sounds like a typical use case for models in backbonejs. You might want to look into that. I am not aware of any way to reload with requirejs.

Come to think of it... why dont you use jQuery AJAX requests, to get the JSON from time to time?

于 2011-12-20T21:15:23.130 回答