Are there any techniques to separate HTML structure from the underlying data?
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 th开发者_运维知识库e 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?
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
精彩评论