DatatTable Showing "No data available in table" but list populated
DatatTable Showing "No data available in table" but list populated
helderfc
Posts: 2Questions: 1Answers: 0
HI,
I have a List of values with data but my datatable show the No data Available.
this is mu script:
$(document).ready(function () {
$.ajax({
url: 'List.aspx/GetClubes',
type: 'GET',
contentType: 'application/json; charset=utf-8',
datatype: 'json',
success: function (data) {
$('#minhatabela').dataTable({
datasrc: data,
columns: [
{ 'data': 'Nome' },
{ 'data': 'Telefone' },
]
});
}
});
});
My aspx return a List<class>.
Can you help me?
Thank you
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This discussion has been closed.
Answers
Try using the
data
option. instead ofdatasrc: data,
usedata: data
. There is not an option calleddataSrc
. There is aajax.dataSrc
option if you are using theajax
option but you are not.Kevin
HI kthorngren, i've change to dataSrc as a test, I have now data and is the same problem.
when I load my page, it stops in the server side script and loads the List from my database with 247 records.
In the datatable appears No data Available
Maybe you need to use JSON.parse() to parse the JSON response into a Javascript object. Everything else looks ok in your code. It just needs debugged to verify the response is what you expect. You can use the browser's network inspector or debug the
data
variable in thesuccess
function. Or post a link to your page or a test case so we can help debug.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin