Reputation: 1471
I have the following JavaScript function...
function loadTable(date: string) {
$('#myDataTable').DataTable({
"bServerSide": false,
"sAjaxSource": "Date/GetValuesFromDate",
"data": date
"bAutoWidth": false,
"bProcessing": true,
"aoColumns": [
{ "sName": "MESSAGE" },
{ "sName": "DATE" },
{ "sName": "STATUS" }
]
"bDestroy":true
});
...
That calls the following controller on my ASP.NET WEb Application...
public class DateController : Controller
{
private RegistrationDbContext _context;
public HomeController(RegistrationDbContext context)
{
_context = context;
}
public ActionResult GetValuesFromDate(string date)
{
// Some code here...
return Json(new
{
aaData = results;
});
}
}
However, the value of the string date is always null. I saw that the loadTable() function does contain the date so I have no clue now how to pass that out to the Controller itself...
I hardcoded the date and everything works wonderfull so the only missing piece here is the binding between the JavaScript function and the Controller...
Any pointers? Thanks!
Upvotes: 0
Views: 321
Reputation: 1217
Trying wrapping up the data param in {} IE
'data': {'date': date}
OR you could directly append it to your source url I think as a query string since it is a GET...
"sAjaxSource": "Date/GetValuesFromDate?date=" + date
Upvotes: 1