JSON might be more flexible. But, is HTML really more complex?

Having related data as attribute started with "data-" is common practice to
bind data to HTML

<div data-id="xxx" data-foo="xxx" >
   ...
</div>


On Sun, Sep 11, 2011 at 6:17 PM, Samuel Richardson <[email protected]>wrote:

> I meant it in the sense of complexity. If you have a very heavy client
> side application (generally one page) then it's easier dealing with
> JSON. Easier in the sense that you could assign the data directly to
> an object in your code for example where as with the HTML you would
> need to parse values out of it if you wanted to access them. It's
> easier to transform from JSON to HTML then it is to get data out of
> the HTML and back into your objects.
>
> Samuel Richardson
> www.richardson.co.nz | 0405 472 748
>
>
>
> On Sun, Sep 11, 2011 at 8:00 PM, Mo Cheng <[email protected]>
> wrote:
> > Hi Samuel,
> > Why "one page applications for example, transforming the JSON client side
> is
> > a must"?
> > For one-page-application, it is still feasible to have XHR response as
> HTML
> > partials.
> > Thanks,
> > -Morgan
> >
> >
> >
> > On Sat, Sep 10, 2011 at 9:54 PM, Samuel Richardson <[email protected]
> >
> > wrote:
> >>
> >> 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]
> >
> > --
> > 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]

Reply via email to