widuri-client/js/data.js

43 lines
1.1 KiB
JavaScript

var table = $('#table-list').DataTable({
"ajax": {
"url": "http://localhost:11000/api/read",
"type": "POST",
"dataSrc": "data",
"contentType": "application/json",
"data": function(d) {
// Customize the data payload sent in the POST request
return JSON.stringify({});
},
"error": function (xhr, error, thrown) {
console.error('Error fetching data:', thrown);
console.error('Response:', xhr.responseText);
}
},
"columns": [
{
"data": "id",
"render": function(data, type, row) {
return data;
}
},
{
"data": "name",
"render": function(data, type, row) {
return data;
}
},
{
"data": "phone",
"render": function(data, type, row) {
return data;
}
},
{
"data": null,
"render": function(data, type, row) {
return `<button>Update</button> <button>Delete</button>`;
}
},
],
})