Вставить ответ ajax в html

Мне нужно вставить ответ ajax в html: ajax возвращает group1.html, как его вставить в group.html?

group.html

{% include 'main/group1.html' %}

<script>
    function loadTable() {
        let xhttpTableGrops = new XMLHttpRequest()
        xhttpTableGrops.onreadystatechange = function (data) {
            if (this.readyState === 4 && this.status === 200) {
                document.getElementById("table_person_id").innerHTML = this.response
            }
        }
        xhttpTableGrops.open("GET", "/main/url_to_django/load_table/", true)
        xhttpTableGrops.send()
    }
</script>

group1.html

<tbody id="table_person_id">
    {% if persons %}
    {% for person in persons %}
    <tr>
        <th scope="row"><div><input class="form-check-input" type="checkbox" id="checkboxNoLabel1" value="" aria-label="..."></div></th>
        <th scope="row">{{forloop.counter}}</th>
        <th scope="col">{{person.Id_Group}}</th>
        <th scope="col">{{person.get_Type_Participation_display}}</th>
        <th scope="col">{{person.display_id_people}}</th>
        <th scope="col">{{person.Competencies}}</th>
        <td>
            <button value="{{person.Id_Group}}" onclick="delete_person(this.value)">Удалить</button>
        </td>
    </tr>
    {% endfor %}
    {% endif %}
</tbody>

Views.py

class Groups(CreateView):
    error = ''
    form_class = GroupCheckResultMeetingCreationMultiForm
    success_url = reverse_lazy('group')
    template_name = 'main/group.html'

def load_table(request):
    error = ''
    id_incidents = request.session.get('Id_Incidents', 'ничего не передано')

    if request.method == "GET":
        if request.user:
            try:
                # persons = AkpGroup.objects.get(Id_Incidents=77)  # запрос в базу данных
                persons = AkpGroup.objects.filter(Id_Incidents=120)  # запрос в базу данных

                # post = AkpPeople.objects.filter(Id_People=Id_Group)
            except AkpGroup.objects.DoesNotExist:
                persons = None

            # else:
            #     error = 'id_incidents не обнаружен'
            return render(request, 'main/group1.html', {"persons": persons})
        else:
            return HttpResponse(status=403)
    else:
        return HttpResponse(status=405)

Urls.py

app_name = "main"

urlpatterns = [
    path('', views.start, name="start"),
    path('group', views.Groups.as_view(), name='group'),

    path(
        'url_to_django/load_table/',
        views.load_table,
        name='load_table')
Вернуться на верх