I was wondering what the best option would be for doing ajax calls to update a list of usernames. I can either
a. do a ajax call and get the user object back and build the html and append it into a div
build_html = function(obj) {
html = 'username - ' + obj.username
$('#container').append(html);
}
b. do a ajax call and have the django return back the html.
response = render_to_response ('user_item_template.html', {'user' : user})
return response._container
If the response is successful I then append this to the container div.
Are there any cons to doing it with method 'b' because depending on the situation building html in javascript can have problems such as unescaped characters and it's just messy in general.
Thanks