DataTables cannot recognize data from DOM

DataTables cannot recognize data from DOM

netpumbernetpumber Posts: 4Questions: 0Answers: 0
edited June 2013 in General
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?

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Please link to a test case.

    Allan
  • netpumbernetpumber Posts: 4Questions: 0Answers: 0
    Here is a test but without the real jQuery script because the server which running has not internet connection.

    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.
  • netpumbernetpumber Posts: 4Questions: 0Answers: 0
    No idea anyone?
This discussion has been closed.