f is undefined
f is undefined
ombak
Posts: 4Questions: 0Answers: 0
Hai all advance, I have problem when use dataTables, I can not load my table this my code;
[code]
function dataSiswa_loadTable() {
$query = db_query('SELECT student_id, nama_foto, lokasi_foto, student_reg, student_name, jenis_kelamin, status_kesiswaan FROM {ed_student}');
while($row = db_fetch_array($query)) {
$data[] = array( $row['student_id'],
$row['nama_foto'],
$row['lokasi_foto'],
$row['student_reg'],
$row['student_name'],
$row['jenis_kelamin'],
$row['status_kesiswaan'] );
}
//...ubah kedalam json
print (json_encode($data));
exit();
}
[/code]
and this my javascript;
[code]
//...set datatable
myTable = $("#table1").dataTable({
"fnDrawCallback" : function() {
update(this);
view(this);
},
"bPaginate": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"bSortClasses": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": Drupal.settings.basePath + "eduDesign/pengelolaan_siswa/dataSiswa_loadTable",
'aoColumns': [ { 'sName' : 'id', 'bVisible': false },
{ 'sName' : 'nama_foto', 'bVisible': false },
{ 'sName' : 'lokasi_foto', 'bVisible': false },
{ 'sName' : 'student_reg', 'sWidth': '40%' },
{ 'sName' : 'student_name' },
{ 'sName' : 'jenis_kelamin' },
{ 'sName' : 'status_kesiswaan' }],
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"error": function (xhr) {
$j('#messages').text(xhr.responseText);
}
} );
}
});
[/code]
and this my result;
[code]
[["22",null,null,"TN2450","Husein Sastra Negara","Laki-laki","Calon Siswa"],["21",null,null,"TN0012","Ken Zanetti Saputra","Laki-laki","Siswa Aktif"],["19",null,null,"TN2012001","Sukma Wijaya Saputra","Laki-laki","Calon Siswa"],["23",null,null,"TN2012009","Surya Atmaja","Laki-laki","Calon Siswa"],["24",null,null,"TN009","Susie Susanti","Laki-laki","Calon Siswa"],["25",null,null,"TN0010","Blanka","Laki-laki","Calon Siswa"],["26",null,null,"TN250","Rush T","Laki-laki","Calon Siswa"]]
[/code]
and error message is;
[quote]f is undefined[/quote]
Regards,
ombak
[code]
function dataSiswa_loadTable() {
$query = db_query('SELECT student_id, nama_foto, lokasi_foto, student_reg, student_name, jenis_kelamin, status_kesiswaan FROM {ed_student}');
while($row = db_fetch_array($query)) {
$data[] = array( $row['student_id'],
$row['nama_foto'],
$row['lokasi_foto'],
$row['student_reg'],
$row['student_name'],
$row['jenis_kelamin'],
$row['status_kesiswaan'] );
}
//...ubah kedalam json
print (json_encode($data));
exit();
}
[/code]
and this my javascript;
[code]
//...set datatable
myTable = $("#table1").dataTable({
"fnDrawCallback" : function() {
update(this);
view(this);
},
"bPaginate": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"bSortClasses": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": Drupal.settings.basePath + "eduDesign/pengelolaan_siswa/dataSiswa_loadTable",
'aoColumns': [ { 'sName' : 'id', 'bVisible': false },
{ 'sName' : 'nama_foto', 'bVisible': false },
{ 'sName' : 'lokasi_foto', 'bVisible': false },
{ 'sName' : 'student_reg', 'sWidth': '40%' },
{ 'sName' : 'student_name' },
{ 'sName' : 'jenis_kelamin' },
{ 'sName' : 'status_kesiswaan' }],
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"error": function (xhr) {
$j('#messages').text(xhr.responseText);
}
} );
}
});
[/code]
and this my result;
[code]
[["22",null,null,"TN2450","Husein Sastra Negara","Laki-laki","Calon Siswa"],["21",null,null,"TN0012","Ken Zanetti Saputra","Laki-laki","Siswa Aktif"],["19",null,null,"TN2012001","Sukma Wijaya Saputra","Laki-laki","Calon Siswa"],["23",null,null,"TN2012009","Surya Atmaja","Laki-laki","Calon Siswa"],["24",null,null,"TN009","Susie Susanti","Laki-laki","Calon Siswa"],["25",null,null,"TN0010","Blanka","Laki-laki","Calon Siswa"],["26",null,null,"TN250","Rush T","Laki-laki","Calon Siswa"]]
[/code]
and error message is;
[quote]f is undefined[/quote]
Regards,
ombak
This discussion has been closed.
Replies
http://datatables.net/release-datatables/examples/data_sources/server_side.html