$("#searchbutton").click(function(){ const audid = document.getElementById('auditory') $.ajax({ url: "/searchonaud", type: "get", contentType: 'application/json', dataType: 'json', data: { auditory: audid.value }, success: function(response){ var data = response; const table = document.getElementById('datatable') table.innerHTML = '' var headTable = ' Инв. номерНазваниеАудитория Проверено ' table.innerHTML += headTable var tr ="" data.forEach(element => { tr += '' + element.inv_number + '' tr += '' + element.oboruds_id + '' tr += '' + element.auditory_name + '' tr += '' + '\n' + '' tr += '' }); table.innerHTML += tr } }) })