I have a controller action with parameters that returns json data to feed jQuery datatable. So far I'm getting an empty table and ajax error: "...For more information about this error, please see http://datatables.net/tn/7" with the message "Loading..." in the table. Any help is highly appreciated.
public ActionResult GetItems(String description, string linenumber)
{
---retracted
return Json(new { data = itemList }, JsonRequestBehavior.AllowGet);
}
Line Number: <input type="text" id="myInput1"><br>
Description: <input type="text" id="myInput2"><br>
<table class="table" id="ItemsTable">
<thead>
<tr>
<th>ID</th>
<th>Quantity</th>
</tr>
</thead>
</table>
What I have tried:
$(document).ready(function () {
var lnbr = $("#myInput1").val();
var desc = $("#myInput2").val()
var oTable = $('#ItemsTable').dataTable({
"ajax" : {
"url" : "/Home/GetItems",
"type" : "get",
"datatype" : "json",
"data" : { description:desc, linenumber: lnbr}
},
"columns": [(
{"data" : "ID", "autowidth" : true },
{"data" : "Qty", "autowidth" : true },
)]
});
});