开发者

Generate the UI in client side or Server side?

开发者 https://www.devze.com 2023-03-02 18:11 出处:网络
Here is two approaches: First, write a JS UI engine on the Client side, and then communicate to server using json, when received the require json data, generate the required UI on the client side.

Here is two approaches: First, write a JS UI engine on the Client side, and then communicate to server using json, when received the require json data, generate the required UI on the client side.

The second approach is the user make request, the serve开发者_开发百科r side get the json, generate the UI, then output the html, and inject the html code... ...

Which ways to do is better?? Thank you


If you're already running scripts on the client the only real benefit to generating HTML for AJAX updates server-side (as opposed to pure client-side DOM manipulation) is to reuse existing control generating code that you don't want to port to JavaScript. There are several downsides to injected HTML prepared elsewhere, including security problems that will arise from the use of innerHTML.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号