datatable and json
datatable and json
nicolas69
Posts: 11Questions: 0Answers: 0
hi,
I'm a noob in javascript and php.
I'm trying to use datatable with ajax.But it's not working.
Here is my code:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "get_data.php"
} );
} );
[/code]
Here is my return of json in get_data.php:
[code]{"sEcho":0,"iTotalRecords":"37","iTotalDisplayRecords":"37","aaData":[[" TREXOTIQUE","488480070","mr name","","BOX 20 Kva",null,"60 MOIS","FRED","","","RETRACTE",""],["WYYWICH","789352598","mr name","","BOX 10KVA",null,"60 MOIS","FRED","","","gh",""],["CAPUCINNO GOUR","507606333","mr name","","BOX 10KVA",null,"60 MOIS","FRED","2125,53","06\/02\/2013","",""],["LEEDIVE","514718675","M mr name","","BOX 20 Kva",null,"60 MOIS","FRED","2125,53","06\/02\/2013","",""],["TARIA OLES","535231583","mr name","","BOX 10KVA",null,"60 MOIS","FRED","","","",""]]}[/code]
and my html table:
[code]
[/code]
my page is blank there is nothing
I'm a noob in javascript and php.
I'm trying to use datatable with ajax.But it's not working.
Here is my code:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "get_data.php"
} );
} );
[/code]
Here is my return of json in get_data.php:
[code]{"sEcho":0,"iTotalRecords":"37","iTotalDisplayRecords":"37","aaData":[[" TREXOTIQUE","488480070","mr name","","BOX 20 Kva",null,"60 MOIS","FRED","","","RETRACTE",""],["WYYWICH","789352598","mr name","","BOX 10KVA",null,"60 MOIS","FRED","","","gh",""],["CAPUCINNO GOUR","507606333","mr name","","BOX 10KVA",null,"60 MOIS","FRED","2125,53","06\/02\/2013","",""],["LEEDIVE","514718675","M mr name","","BOX 20 Kva",null,"60 MOIS","FRED","2125,53","06\/02\/2013","",""],["TARIA OLES","535231583","mr name","","BOX 10KVA",null,"60 MOIS","FRED","","","",""]]}[/code]
and my html table:
[code]
[/code]
my page is blank there is nothing
This discussion has been closed.
Replies
Allan
I'm wondering now if i really need ajax to get my data from my DB...
I think i will have about 5000 rows.
Is it possible to add rows with ajax, i mean i want to add row and my table display new rows without refreshing the page?
And yes, you can use fnAddData to add rows on the client-side.
Allan