HTML template + JSON vs Server HTML

后端 未结 2 836
情歌与酒
情歌与酒 2021-01-02 08:31

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?
2条回答
  •  無奈伤痛
    2021-01-02 08:55

    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.

提交回复
热议问题