Thanks for the code snippet Josh.  It's exactly what I was looking
for.  Certainly load works as well.  At this point I am trying to
understand various options for producing data on an intranet.  In the
past I have written asp pages which format the HTML and then use ajax
(with or without jquery) to insert the dormatted data.  I have assumed
that I might see a performance benefit by transporting raw data and
formatting it locally.  I'm not sure if that holds true.  Any
thoughts?

On Mar 14, 7:05 pm, Josh Powell <seas...@gmail.com> wrote:
> What I don't like about that method is the loss of ease of updating
> and reuse of code later on.  If you stick it in a table coming back,
> and need the some data somewhere else you cannot reuse it.  Also,
> changing things on server side requires recompiling in a java
> environment, which is a drag for html development.  In a PHP
> environment it wouldn't be as big of a deal though.
>
> It's also a matter of separating the data from the layout.  I prefer
> making an ajax request to retrieve data and do all of my layout/
> styling and interactivity in javascript.  That way it never becomes
> confusing where to go to update things.  If it's a data issue, you go
> to the server, if it's a layout/styling issue then the problem is in
> the javascript.  When you start breaking that line by putting html in
> the server side code, things can get messy.
>
> That said, what you are talking about is a perfectly valid way to
> code.
>
> On Mar 14, 2:10 pm, donb <falconwatc...@comcast.net> wrote:
>
> > Then I must be missing something:
>
> > $("#placetoinsert").load("path/to/url");
>
> > would do the same thing, with the tableHTML constructed on the server
> > side.
>
> > On Mar 14, 5:02 pm, Josh Powell <seas...@gmail.com> wrote:
>
> > > Because it puts it in the javascript and lets you easily manipulate it
> > > with javascript.  If you get html back from the server, it's more
> > > difficult to manipulate.
>
> > > $.getJson('path/to/url',  function(data) {
> > >     var tableHTML = '<table>';
> > >     $.each(data.aaData, function() {
> > >          tableHTML += '<tr><td>' + this[0] + '</td><td>' + this[1] +
> > > '</td></tr>';
> > >     });
> > >     tableHTML += '</table>';
> > >     $('#placeToInsert').append(tableHtml);
>
> > > });
>
> > > On Mar 14, 12:30 pm, donb <falconwatc...@comcast.net> wrote:
>
> > > > If that's all your going to do with it, why not return a table from
> > > > the server and simply .load() it?  No transformation required in that
> > > > case.
>
> > > > On Mar 14, 9:23 am, finco <mbeck...@gmail.com> wrote:
>
> > > > > Sorry if this is a duplicate post - doesn't look like the last one
> > > > > went through.
>
> > > > > I've seen several examples of how to process json data with .each when
> > > > > the field names come over with json.  My data, howver, looks like the
> > > > > following:
>
> > > > > {"aaData": [
> > > > > ["1001-00-1535.000","Tenant Improvements"],
> > > > > ["1001-00-1558.000","Selling costs"],
> > > > > ["1001-00-1560.000","Financing Fees"],
> > > > > ["1001-00-1560.001","Financing Fees - Legal"],
> > > > > ["1001-00-1565.000","Lease Costs"],
> > > > > ["1001-00-1565.001","Lease Costs -Legal"],
> > > > > ["1001-00-1565.002","Lease Costs - Brokerage"],
> > > > > ["1001-00-1570.000","Legal Fees"]
> > > > > ]}
>
> > > > > How would I drop this data into a table?
>
> > > > > Thanks in advance for your help.

Reply via email to