HTML模板+ JSON与服务器HTML [英] HTML template + JSON vs Server HTML

查看:108
本文介绍了HTML模板+ JSON与服务器HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Ajax结果:


    li>在服务器上生成的HTML
  1. 返回将在模板中使用的数据

我认为服务器渲染的优点是逃避,更复杂的逻辑,需要大量数据!

'在客户端处理json创建标记'会减少正在传输的数据的大小。

您的问题的答案取决于您开发的应用程序类型。
说明如果您有一个应用程序在页面上显示(不断更新)状态消息列表;发送html会更重,因为它将包含用于布置状态消息的所有标记。相反,一个json对象将足够轻便,并且可以在客户端轻松处理为所需的标记。

What do you think is better?

Use for Ajax result:

  1. HTML that was generated on server
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆