Compare commits
2 Commits
588a1d0a90
...
65f4657d4d
Author | SHA1 | Date | |
---|---|---|---|
65f4657d4d | |||
f2975a0089 |
@ -4,12 +4,17 @@
|
|||||||
<link rel="stylesheet" href="//cdn.datatables.net/2.3.2/css/dataTables.dataTables.min.css">
|
<link rel="stylesheet" href="//cdn.datatables.net/2.3.2/css/dataTables.dataTables.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<input type="text" placeholder="Name" />
|
||||||
|
<input type="text" placeholder="Phone" />
|
||||||
|
<button>Create</button>
|
||||||
|
<hr>
|
||||||
<table id="table-list">
|
<table id="table-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Phone</th>
|
<th>Phone</th>
|
||||||
|
<th>Act</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@ -20,9 +25,7 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||||
<script src="//cdn.datatables.net/2.3.2/js/dataTables.min.js"></script>
|
<script src="//cdn.datatables.net/2.3.2/js/dataTables.min.js"></script>
|
||||||
<script src="js/carrack.js"></script>
|
<script src="js/carrack.js"></script>
|
||||||
<script>
|
<script src="js/data.js"></script>
|
||||||
var table = $('#table-list').DataTable({})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
42
js/data.js
Normal file
42
js/data.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user