Backbone.js 中 AJAX 调用的正确位置在哪里?

发布于 2024-10-10 01:29:54 字数 248 浏览 0 评论 0原文

我正在为我正在构建的新应用程序学习 Backbone.js。

我需要执行 AJAX 调用来获取模型对象的更多属性(图像、书名和描述)。

此调用的正确位置在哪里?在模型、视图还是其他地方?特别与 Backbone.js MVC 模型相关。

其他信息

我使用的是 LocalStorage 而不是服务器。 AJAX 调用将针对 Web 服务 API,并且仅构成我的实际模型数据的一部分。

I'm learning Backbone.js for a new app I'm building.

I need to perform an AJAX call to get more properties for my model object (image, title & description of a book).

Where is the correct place for this call? In the Model, View or somewhere else? specifically related to Backbone.js MVC model.

Additional Info

I'm using LocalStorage and not a server. The AJAX call will be to a web service API and constitutes only part of my actual model data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二智少女 2024-10-17 01:29:54

如果您已正确配置模型,则只需调用 model.fetch() 即可向您配置的任何 url 发出 HTTP GET,并使用以下结果刷新模型服务器。

If you have properly configured your model you can just call model.fetch() which will issue a HTTP GET to whatever url you have configured and refresh the model with the results from the server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文