$(document).ready(function () {
$.ajax({
url: '__',
method: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function (data) {
let len = data.length;
let table_td = `<tr>
<th>id</th><th>title</th><th>description</th><th>created_at</th><th>updated_at</th><th>update</th><th>delete</th>
</tr>`;
for (let i = 0; i < len; i++) {
table_td += `<tr>`;
table_td += `<td>${data[i]['article_id']}</td>`;
table_td += `<td>${data[i]['title']}</td>`;
table_td += `<td>${data[i]['short']}</td>`;
table_td += `<td>${data[i]['created_at']}</td>`;
table_td += `<td>${data[i]['updated_at']}</td>`;
table_td += `<td><form action="__" method="post"><input type="text" hidden name="id" value="${data[i]['article_id']}"><input type="submit" class="btn btn-primary" value="Update"></form></td>`;
table_td += `<td><form action="__" method="post"><input type="text" hidden name="id" value="${data[i]['article_id']}"><input type="submit" class="btn btn-primary" value="Delete"></form></td>`;
table_td += `</tr>`;
}
$(".success").html(`<table class="table table-success table-striped">${table_td}</table>`);
}
});
})
</script>