HTML模板+ JSON与服务器HTML [英] HTML template + JSON vs Server HTML
问题描述
- 返回将在模板中使用的数据
li>在服务器上生成的HTML
我认为服务器渲染的优点是逃避,更复杂的逻辑,需要大量数据!
'在客户端处理json创建标记'会减少正在传输的数据的大小。您的问题的答案取决于您开发的应用程序类型。
说明如果您有一个应用程序在页面上显示(不断更新)状态消息列表;发送html会更重,因为它将包含用于布置状态消息的所有标记。相反,一个json对象将足够轻便,并且可以在客户端轻松处理为所需的标记。
What do you think is better?
Use for Ajax result:
- HTML that was generated on server
- Return Data that would be used within template?
I think plus for server rendering are escaping, easy more complex logic, when much data needed!
One advantage I see with 'processing json to create markup' on client side is decrease in size of the data being transferred.
The answer to your question would depend on what kind of application you are developing. Say if you have an application where you display a list of (constantly updating) status messages on a page; sending the html would be heavier as it would contain all markup for laying out the status messages. Instead, a json object would be light enough and can be processed easily on client side into required markup.
这篇关于HTML模板+ JSON与服务器HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!