数据库访问通常是应用程序中最慢的部分,因此为了适应这种情况,是否有任何技术可以通过以下方式响应请求:
- 发送静态 HTML 结构,
- 在数据存储上运行查询
- 在数据从查询返回后 ,然后推送数据向客户端(可能是 JSON)
- 使用 JavaScript 通过添加文本或更改值属性来更新 HTML
首先,这是一个坏主意吗?在过去几天的研究中没有发现任何类似的东西,我认为这是一个糟糕的结果。然而,如果不是的话,有可能吗?是否有成熟的技术可以做到这一点?
Database access is often the slowest part of an application, so to accommodate that are there any techniques to respond to a request by:
- sending a static HTML structure
- running a query on the data store
- once the data returns from the query, then push the data to the client (perhaps in JSON)
- use JavaScript to update the HTML by adding text or changing value attributes
First, is this a bad idea? Having not found anything resembling this in my research over the last couple days I assume it is a bad one. However, if it is not, is it possible? And are there established techniques for doing this?
发布评论
评论(2)
正如已经说过的,这基本上就是“ajax 应用程序”。如今它们很容易编写,主要是因为框架的数量很多。
查看 http://sproutcore.com、http://javascriptmvc.com/ 和 http://cappuccino.org/ 这些是“重量级”解决方案,但取决于您正在建设中,这可能完全满足您的需求。
如果这些看起来不像你想要的东西,我会看看 http://dojotoolkit.org它是一个 JavaScript 框架,几乎可以以集成的方式处理您可以想象到的所有事情。
如果您已经在使用 jquery,最好的选择可能是 http://documentcloud.github.com/backbone/ ,或 http://knockoutjs.com/,或 http://sammyjs.org/。
As has already been said, this is basically what an "ajax application" is. They are very easy to write nowadays, mostly because of the number of frameworks out there.
Check out http://sproutcore.com, http://javascriptmvc.com/ and http://cappuccino.org/ Those are "heavyweight" solutions, but depending on what you are building, that may suit your needs perfectly.
If those don't look like the sort of thing you want, I would take a look at http://dojotoolkit.org It is a javascript framework that pretty much handles everything you could imagine wanting to do in an integrated sort of way.
If you are already using jquery, the best bet may be something like http://documentcloud.github.com/backbone/, or http://knockoutjs.com/, or http://sammyjs.org/.
http://api.jquery.com/category/plugins/templates/
http://stanlemon.net/projects/jquery-templates.html
http://api.jquery.com/category/plugins/templates/
http://stanlemon.net/projects/jquery-templates.html