What's the correct way to do an ajax request, I've seen people using a returning render_to_string so that they can do all their formatting within python using the template language. eg~
return render_to_string('calendar.html', {
'self' : self,
'month' : self.today.month,})
with this as the javascript:
$('#django_calendar_response').html(response)
But I've also seen people formatting their output within javascript using dom functions such as
return HttpResponse(serializers.serialize("json",
ilst, relations=('user',)), "application/json")
where the javascript is
items_display=function(items){
return LI(null,
A({'class':'userlink',
'href':'/url/user/'+items.fields.user.fields.name},
items.fields.user.fields.name),
is one of these correct and the other wrong? should I format my output in javascript or within python?