I have a django view, and this view returns a table that is populated asynchronously with an ajax call.
In terms of design, with which I should follow:
- the django view called via ajax returns the contents of the table as a json response containing html markup for each cell. The javascript callback handler takes the contents and removes them in the table cells.
- the django view called via ajax returns pure data about what should go to the table, again as a json response. The async javascript callback takes the data, formats it with the proper markup, and puts it in the table.
In other words, who should be responsible for marking up the formatting of the contents of the cell? view or javascript?
I will be tempted to say the first, as the view already returns the marked content. If it returns json containing tagged content, there is not much difference.
I would like to hear your point of view.
source
share