I've basically stared to do the following when creating a REST service:
- HTML is requested
- service returns the desired web page but without the requested "resource", eg. data
- web page contains JavaScript that issues AJAX request to the same service (different content-type)
- service then returns the actual data (JSON) and the page displays it
On one side it seems inefficient (2 requests) but then were I used this, "performance is of no concern", meaning low traffic internal app and the web sites are simple and load fast.
The reason I ended up with this is that the web page can then be almost pure Html + JavaScript and almost no server-side stuff is required, especially no loops, to create tables and stuff like that (which I think is very ugly compared to things like slickgrid), e.g. separation of data and view.
Now before I get to using this, is this a good idea or should I just stop doing it?