DataTable warning: table id="myTable" = request unknown Parameter '0' for row '0'
DataTable warning: table id="myTable" = request unknown Parameter '0' for row '0'
Dear Prof,
Im new for MVC and jQuery and i learning now.
i already refer many article and also YouTube video. but still i not able to figure out why the error occurred. kindly release me from this issue. some document says have to include table name after column name. etc: (myTable.ContactName) i tried but same error.
Im realy looking for the solution if possible let me know why its happen
below image:
my jQuery code and Controler code
@{
ViewBag.Title = "DatatableForm";
}
<h2>Part 1 : Implement jQuery DataTable in ASP.Net MVC</h2>
<div>">
<table id="myTable">
<thead>
<tr>
<th>Employee Name</th>
<th>Company</th>
<th>Phone</th>
<th>Country</th>
<th>City</th>
<th>Post Code</th>
</tr>
</thead>
</table>
</div>
@*Load Datatable css*@
<link href="~/Content/DataTable/css/jquery.dataTables.min.css" rel="stylesheet" />
@*Load Datatable js*@
@section Scripts{
@* <script src="~/Content/DataTable/js/jquery.dataTables.min.js"></script>*@
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#myTable').DataTable({
"ajax": {
"url": "/home/loaddata",
"type": "GET",
"datatype": "json"
},
"column": [
{ "data": "ContactName" },
{ "data": "CompanyName" },
{ "data": "Phone" },
{ "data": "Country" },
{ "data": "City" },
{ "data": "PostCode"}
]
});
});
</script>
}
My controler
public ActionResult loaddata()
{
using (var dc = new ScorpiusLearningEntities())
{
var data = dc.Customers.OrderBy(d=> d.CustomerName).ToList();
return Json(new {data}, JsonRequestBehavior.AllowGet);
}
}
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
Have you followed the instructions in the link the error gives? What is the server returning (given that it is not valid JSON)?
Allan