POST https://localhost:7002/Master/SupplierPancang/GetData 404 ?
POST https://localhost:7002/Master/SupplierPancang/GetData 404 ?
dewihs218
Posts: 1Questions: 1Answers: 0
var dataTable;
$(document).ready(function () {
$('#filterButton').click(function () {
loadDataTable();
});
});
function loadDataTable() {
//var url = '/Master/SupplierPancang/Filter';
//if (dataTable) {
// // Hancurkan tabel sebelumnya jika sudah ada
// dataTable.destroy();
//}
dataTable = $('#supplierpcgTable').DataTable({
"ajax": {
"url": "/Master/SupplierPancang/GetData",
"type": "POST",
"dataType": "JSON",
//"contentType": "JSON",
"data": function (d) {
return $.extend({}, d, {
"FilterDateChecked": $("#FilterDateChecked").val().trim(),
"FilterDateChecked": $('#FilterDateChecked').prop('checked'),
"CreatedDateStart": $('#CreatedDateStart').val(),
"CreatedDateEnd": $('#CreatedDateEnd').val(),
"SupplierChecked": $('#SupplierChecked').prop('checked'),
"Supplier": $('#Supplier').val(),
"NotActive": $('#NotActive').prop('checked')
});
}
},
"columns": [
{
"data": null, "render": function (data, type, row, meta) {
// Mengembalikan nomor urut berdasarkan indeks data
return meta.row + 1;
}, "width": "5%"
}, // Kolom penomoran
{ "data": "rmSupplierID", "width": "5%", "visible": false },
{ "data": "supplierID", "width": "10%" },
{
"data": "approve1Date", "width": "10%",
"render": function (data) {
if (data && data !== "0001-01-01T00:00:00") {
return data;
} else {
return "<span style='background-color: rgb(235, 150, 179);'></span>";
}
}
},
{ "data": "fotoSupplier", "width": "10%" },
{ "data": "fotoSupplierBy", "width": "10%" },
{ "data": "fotoSupplierDate", "width": "10%" },
{ "data": "filter", "width": "10%" },
{
"data": "id",
"render": function (data) {
return `
<div class="text-md-center" role="group">
<a href="/Master/SupplierPancang/Upsert?id=${data}"
class="btn btn-outline-warning btn-sm"> <i class="fas fa-pencil-alt"></i> Edit</a>
<a onClick="Deleted('/Master/SupplierPancang/delete/${data}')"
class="btn btn-outline-danger btn-sm"> <i class="fas fa-trash"></i> Delete</a>
</div>`;
},
"width": "15%"
}
],
"rowCallback": function (row, data, index) {
if (data.approve1Date && data.approve1Date !== "0001-01-01T00:00:00") {
$(row).addClass('null-row');
}
}
});
}
[HttpPost]
//public async Task<ActionResult> GetData(FilterMasterSupplier filter)
public async Task<IActionResult> GetData(FilterMasterSupplier info)
{
var list = new List<SupplierDTO>();
var token = HttpContext.Session.GetString(SD.SessionToken);
var response = await _mastersupplierService.GetMasterSupplierPancangAsync<APIResponse>(info, token);
if (response != null && response.IsSuccess)
{
try
{
list = JsonConvert.DeserializeObject<List<SupplierDTO>>(Convert.ToString(response.Result));
}
catch (Exception ex)
{
// Handle any exception that might occur during conversion
// You can add an error message or appropriate action here
//return BadRequest("An error occurred during data conversion.");
}
}
return Json(new { data = list });
}
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
So what is your question?
I think you'll need to ask on Stack overflow or somewhere with more knowledge of .NET routing. This isn't specific to DataTables, but rather it sounds like a routing error since the server is telling us that
/Master/SupplierPancang/GetData
doesn't exist.Allan