Split data of an Ajax call to multiple div in Django
I have this ajax call
$.ajaxSetup({
data: {txtSearch: $('#txtSearch').val(), prefilter: $('#prefilter').val(),csrfmiddlewaretoken: '{{ csrf_token }}' },});
$.ajax({
type: "POST",
url: "article-filter2/",
success: function (data) {
$("#div_tab_search_results_contact").html(data.html_table); // working
$("#div_tab_search_results_company").html(data.html_table); // not working if I call it a second time
}
});
data.html_table
contains 2 tables and I would like to put the first one in $("#div_tab_search_results_contact")
and the second one in $("#div_tab_search_results_company")
based on the id's of the tables.
I tried to search but what I found was in PhP Not able to split the Ajax response in separate Div
Here is the end of my view.py article-filter2/ :
def article_filter2(request):
data = dict()
[...]
data['html_table'] = render_to_string('grid.html', {'available_lessons': available_lessons,
'available_lessons_company': available_lessons_company
},request=request)
return JsonResponse(data)
Thanks to anybody that can help me