Generate the UI in client side or Server 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.
精彩评论