1👍
You want to use something like JSONReponseMixin and have your view just send the data.
class MyView(JSONResponseMixin, AjaxResponseMixin , TemplateView):
def get_ajax(self, request, *args, **kwargs):
data = ['Country', 'Country']
return self.render_response(json.dumps(data))
When you you view from jquery ajax call it’ll send back only the data and you generate the html.
You can also not do json and have the view return the html containing only the table and replace the html in your page.
Source:stackexchange.com