Hey folks, I have a question which feels stupid but I can't quite say why.
Background:
Imagine a webapp with users and tags. Users tag each other.
I've got one page in the app which displays details about a single tag in relation to a single user. Let's say user 'bob' and tag 'footag'. On this page, I'm displaying two lists: all the people who have tagged bob with 'footag' and all the people bob has tagged 'footag'. let's call these <div id="received'>
and <div id="sent">
Let's say the url for this view is /users/bob/tags/footag
Naturally, these lists are long -- I don't want to load the whole list upon pageview. So I load the first ten for each.
The question
Now I can provide dynamic paging for each of the lists in one of two ways:
- Get the data for the next 10 users as json. Write js to render this data, replacing the contents of the
div
. - Get a rendered "snippet" of html from another well defined URL on my server, say
/users/bob/tags/footag/received?page=1
. I fetch it asynchronously and just replace the contents of the relevant<div>
.
So in one case I fetch data and render it via JS in the browser, the other I fetch rendered data and just plonk it wholesale into the document.
Is there any reason not to use #2? I can't imagine one but I suppose there might be security aspects I'm not considering, or performance, or something else. I'd much prefer to do #2 as it simplifies my life significantly.
Thanks!