I am very new to jquery and Ajax. I’m working with an ActiveX control that draws little sketch documents. When users save a new sketch using this control I send the data back to the server using Ajax. One of my requirements it to show a list of thumbnails in the page of existing sketches.
For this list I’ve deiced to simply use a table, however the problem is what would be the very best way to manage this table using AJax?
I can think of several way to do this:
- Have the Ajax request respond with
an entire new table with all of the
sketch thumb nail links, - or I could respond with all of the rows.
- Another possibility I can think of is to not respond with html at
all but with JSon data that has all of the information I need to build the table and then use Jquery to build the table and append new rows or delete new rows as the users create and delete sketches. - Something else.
What approach would you use?
The important question is this: “Where should the ‘visual display’ part of your code live? Mostly on the server, or mostly on the javascript client?”
Myself, I would send JSON back to the client (#3) and then have the client be responsible for putting the images into a table, using one of a variety of Javascript templating systems, like EJS. This way the server-side doesn’t have to care about how things look, it just has a fairly basic responsibility to organize data and objects.