I made this javascript code:
function ajax(response) {
var dados = response
JSON.parse(dados).forEach( function (registro){
var html = "<tr>"
html += "<td>"
html += registro.nome
html += "</td>"
html += "<td>"
html += registro.sobrenome
html += "</td>"
html += "<td>"
html += registro.telefone
html += "</td>"
html += "<td>"
html += "<div class='btn bg-"+ registro.cor_status +"'>"
html += "<i class='material-icons'>"+registro.icons_status+"</i>"
html += "<span>"+registro.nome_status+"</span>"
html += "</div>"
html += "</td>"
html += "</tr>"
document.getElementById('ajax').innerHTML= html
})
}
But it only displays the last record of the array, eg:
var json = [{"id":"1","nome":"Alex"},{ "id":"2", "nome":"felipe"}, {"id":"3", "nome":"silvia"}]
//retorna so o {"id":"3", "nome":"silvia"}
Can you help make it display every array?