Ajax post method does not fire action controller in ASP .NET CORE 3
Ajax post method does not fire action controller in ASP .NET CORE 3

Hi everyone,
( The same post with highlighted code )
I'm trying to initialise a DataTable after button click and fill it with some Data from database, but the ajax method couldn't find the requested Url and showing me this error on console : "jquery.min.js:2 POST https://localhost:44311/FillIssueTable 404"
and an alert message showing this "DataTables warning: table id=IssueDatatable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3".
Notice That :
i have no pbm with button function.
i tried to to put button type to "submit" and my asp-actiont to my controlller action "FillIssueTable" : my action controller actually fired up and i got raw data on my screen.
i tried many ways to to pass the URL
* https://localhost:44311/Home/FillIssueTable"
* https://localhost:44311/FillIssueTable"
* '@Url.Action("FillIssueTable","Home")'
Help please and thank you
Shiro
[HttpPost]
public async Task<IEnumerable<SlaExport>> FillIssueTable(SLAGeminiModel model)
{
string indicator = model.IndicatorCode;
return await GenericProvider<SlaExport>.Instance.ExecuteDataSetStoredProcedure("GetDataFor"+ indicator, cmd =>
{
cmd.Parameters.Add(new SqlParameter() { ParameterName = "@ProjectId", Value = model.ProjectId });
cmd.Parameters.Add(new SqlParameter() { ParameterName = "@StartDate", Value = model.StartDate});
cmd.Parameters.Add(new SqlParameter() { ParameterName = "@EndDate", Value = model.EndDate });
if (indicator == "BackLog")
cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Date", Value = model.Date });
}, null, true);
}
function InitIssueTable() {
$('#BtnChart').click(function () {
alert("BlaBla")
$('#IssueDatatable').DataTable({
"processing": true,
"responsive": true,
"paging": true,
"searching": true,
"info": false,
"ajax": {
"url": '/FillIssueTable',
"type": "POST",
"datasrc": "",
"error": function () {
}
},
"columns": [
{ "data": "issueCode", "name": "IssueCode" },
{ "data": "issueName", "name": "IssueName" },
{ "data": "issuePriority", "name": "IssuePriority" },
{ "data": "takeOnDuration", "name": "TakeOnDuration" },
],
"bjqueryui": true,
"order": [[0, "desc"]]
});
});
}
Some of my HTML
<form asp-controller="SLA" asp-action="calculatesSLA" asp-anti-forgery="true" method="post">
<div class="col-1">
<button id="BtnChart" type="button" class="btn btn-outline-primary"
onclick="InitIssueTable()">
<i class="fas fa-chart-bar"></i>
</button>
</div>
<div class=" container">
<table id="IssueDatatable" class="table table-responsive-md table-striped text-center table-bordered">
<thead>
<tr>
<th class="text-center" style="width:auto">IssueCode</th>
<th class="text-center" style="width:auto">IssueName</th>
<th class="text-center" style="width:auto">IssuePriority</th>
<th class="text-center" style="width:auto">TakeOnDuration</th>
</tr>
</thead>
</table>
</div>
</form>
Replies
Please don't duplicate posts. I provided a response in your other thread:
https://datatables.net/forums/discussion/59707/ajax-post-method-does-not-fire-action-controller-in-asp-net-core-3#latest
Kevin