When making an AJAX request, only the last record from the loop is displayed. See the code snippet below:
$.ajax({
method: "POST",
url: "{{asset('/num')}}",
dataType: "json",
success: function (data) {
var inf;
var json_x = data;
json_x.forEach(function(item){
inf = '<p>'+ item['id'] +"</p>";
});
insTabl = document.getElementById('table');
insTabl.innerHTML = inf;
}
});
This content is being sent into a div
with the ID of 'table'.