DataTabes Refresh without refreshing page
DataTabes Refresh without refreshing page
TimothyV
Posts: 34Questions: 7Answers: 0
Hi, I have searched the forms and cannot find an answer to this can someone please help?
$(document).ready(function () { $('#example').DataTable(); });$('#example').DataTable().clear();
$('#example').DataTable().ajax.reload();
Script Error: DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
This discussion has been closed.
Answers
Looks like the problem is that you are trying to use
ajax.reload()
without actually using theajax
. It has no URL to reference. You could try usingajax.url().load()
to load data from a new URL.If this doesn't help please explain where you want to refresh the data from.
Kevin
Kevin, thank you for the quick response. I apologize for the confusion, I populate the DataTable in the controller.
var result = from m in db.Customer select m;
return View(result);
So are you returning HTML? DataTables
ajax.reload()
requires that json be used.How are you populating the table initially? Are you using
ajax
for that? If you could link to your page that would be useful.Thanks,
Allan
Allan, thank you for your response. I'm sorry but I do not understand.
View:
$(document).ready(function () { $('#example').DataTable(); });@foreach (var item in Model) {
...
}
Controller:
var result = from m in db.Customer select m;
return View(result);