There's a lot of factors to take into account, but if you have control over the entire environment then I find working with JSON that's transformed using JST templates to be the most flexible way of doing things.
That being said, there are cases for the server rendering HTML and the XHR request inserting it into the page (also, jQuery's live binding can be very helpful in this situation). The server might be configured already for rendering HTML server side, it might be pulling content from existing templates in other areas or in some cases, the backend team might just not be very good or unable to handle JSON for whatever reason. For applications that are very programmatic, one page applications for example, transforming the JSON client side is a must. For more static applications, you can use the HTML bound with live events instead. Samuel Richardson www.richardson.co.nz | 0405 472 748 On Sat, Sep 10, 2011 at 10:50 PM, Martin <[email protected]> wrote: > From a separation and maintenance point of view (I'll leave others to > discuss performance), having a server generate HTML is definitely a bad > thing. I'm working on a several-year-old website at work which has elements > of modern Dojo-based JSON REST services but also older XSLT-generated > server-side HTML generation that's then replaced client-side, and I can > assure you that fixing bugs or altering the code in the old server-generated > HTML "bit" is much, much harder work. > > > On Sat, Sep 10, 2011 at 11:44, Mo Cheng <[email protected]> wrote: > >> Hi All, >> >> In highly AJAX-ified web site, XHR is used to update part of page, which >> basically update partial HTML tags. Then we need to make a decision: >> Should server render the HTML and sent in XHR response? or Should server >> just return JSON data and have browser JavaScript render HTML according to >> JSON data? >> >> Anybody has experience in both approaches? Which is more performant? >> >> >> Thanks, >> -Morgan >> >> -- >> To view archived discussions from the original JSMentors Mailman list: >> http://www.mail-archive.com/[email protected]/ >> >> To search via a non-Google archive, visit here: >> http://www.mail-archive.com/[email protected]/ >> >> To unsubscribe from this group, send email to >> [email protected] >> > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
