Datatable not loading when tablestring loaded in ready function
Datatable not loading when tablestring loaded in ready function
I encountered a problem when I try to load the datatable after I loaded the entire tablestring from an external file using .load().
When I load the table without datatables it workes perfectly fine.
When I paste the tablecode to the same html file I am able to load the datatable without problems.
I need to generate the tablestring in another file and this code has to be loaded in the ready function.
Does anybody have a suggestion how to solve this?
This is my ready(function) code
[code]
$( document ).ready(function() {
$("#div2").load('Ajax/loadTable.php',
{ 'videoId': '<?php echo $video_id ?>'
} );
$('#table_id').dataTable(
{
"iDisplayLength": 100,
"aaSorting": [[0, "asc" ]]
} );
});
[/code]
When I load the table without datatables it workes perfectly fine.
When I paste the tablecode to the same html file I am able to load the datatable without problems.
I need to generate the tablestring in another file and this code has to be loaded in the ready function.
Does anybody have a suggestion how to solve this?
This is my ready(function) code
[code]
$( document ).ready(function() {
$("#div2").load('Ajax/loadTable.php',
{ 'videoId': '<?php echo $video_id ?>'
} );
$('#table_id').dataTable(
{
"iDisplayLength": 100,
"aaSorting": [[0, "asc" ]]
} );
});
[/code]
This discussion has been closed.
Replies
[code]
$("#div2").load('Ajax/loadTable.php',
{ 'videoId': '<?php echo $video_id ?>'
}, function() {
$('#table_id').dataTable(
{
"iDisplayLength": 100,
"aaSorting": [[0, "asc" ]]
} );
});
});
[/code]