const url = 'http://localhost:8000/employees' var empList = [] $.ajax(url) .done((data) => { console.log(data) empList = data renderTable() }) function renderTable() { empList.forEach(emp => { const tr = $('') tr.append(` ${emp.id} ${emp.name} ${emp.city} ${emp.salary} `) tr.find('.editButton').click( () => editEmployee(emp)) tr.find('.delButton').click( () => deleteEmployee(emp.id)) $('#empsBody').append(tr) }) } function deleteEmployee(id) { console.log('törlés...') console.log(id) } function editEmployee(emp) { console.log('szerkesztés...') console.log(emp.name) }