DataTables cannot recognize data from DOM
DataTables cannot recognize data from DOM
Hi.
I have this simple table :
[code]
Choose
Ip
Hostname
Log
Date
[/code]
The tbody fills with function loadLogsTable(); that returns 30 table rows
[code]
function loadLogsTable()
{
jQuery.ajax({
type: "POST",
async : true,
url: "classes/classesController.php",
data: { method: "getLogsList"},
contentType : ('application/x-www-form-urlencoded'),
dataType : "html" ,
success : function(data){
$("#logData").html(data);
}
});
}[/code]
I initialize this table with dataTables but it doesn't paginate them and it looks like it cannot see table's data. I cannot also search in table's data.
[code]
$(document).ready(function()
{
loadLogsTable();
$('#logsTable').dataTable({ // Init pagination
"aoColumnDefs": [{ "bSortable": false, "aTargets": [ 0,1,2,3,4] } ],
"sPaginationType": "full_numbers" ,
"bLengthChange": false,
iDisplayLength": 10
});
});[/code]
Any advice?
I have this simple table :
[code]
Choose
Ip
Hostname
Log
Date
[/code]
The tbody fills with function loadLogsTable(); that returns 30 table rows
[code]
function loadLogsTable()
{
jQuery.ajax({
type: "POST",
async : true,
url: "classes/classesController.php",
data: { method: "getLogsList"},
contentType : ('application/x-www-form-urlencoded'),
dataType : "html" ,
success : function(data){
$("#logData").html(data);
}
});
}[/code]
I initialize this table with dataTables but it doesn't paginate them and it looks like it cannot see table's data. I cannot also search in table's data.
[code]
$(document).ready(function()
{
loadLogsTable();
$('#logsTable').dataTable({ // Init pagination
"aoColumnDefs": [{ "bSortable": false, "aTargets": [ 0,1,2,3,4] } ],
"sPaginationType": "full_numbers" ,
"bLengthChange": false,
iDisplayLength": 10
});
});[/code]
Any advice?
This discussion has been closed.
Replies
Allan
http://jsfiddle.net/MmDFN/1/
This is what getLogList function does http://pastebin.com/27RLKuzg
It returns this html code and the jQuery script add this code into tbody.
I cannot understand why it is working in jsfiddle but not in the way with jQuery script.