Help me please Build DataTable with JSON
Help me please Build DataTable with JSON
anthonny2890
Posts: 5Questions: 0Answers: 0
Hello, I need help please. How to build a table from my data in Json format using DataTables?
I write this code, but it did not work:
[code]
var testdata = '[{"name":"Jhon","age":"23","sex":"M","phone":"210-828-5555"},{"name":"Barack","age":"30","sex":"M","phone":"210-828-4444"}]';
$('#example').dataTable(
{
"aaData": testdata,
"aoColumns": [{ "mDataProp": "name" },
{ "mDataProp": "age" },
{ "mDataProp": "sex" },
{ "mDataProp": "phone" }
]
}
);
[/code]
Thanks!
I write this code, but it did not work:
[code]
var testdata = '[{"name":"Jhon","age":"23","sex":"M","phone":"210-828-5555"},{"name":"Barack","age":"30","sex":"M","phone":"210-828-4444"}]';
$('#example').dataTable(
{
"aaData": testdata,
"aoColumns": [{ "mDataProp": "name" },
{ "mDataProp": "age" },
{ "mDataProp": "sex" },
{ "mDataProp": "phone" }
]
}
);
[/code]
Thanks!
This discussion has been closed.
Replies
[code]
[/code]
[code]
$('#example').dataTable(
{
"aaData": [{"name":"Jhon","age":"23","sex":"M","phone":"210-828-5555"},{"name":"Barack","age":"30","sex":"M","phone":"210-828-4444"}],
"aoColumns": [{ "mDataProp": "name" },
{ "mDataProp": "age" },
{ "mDataProp": "sex" },
{ "mDataProp": "phone" }
]
}
);
[/code]
Thanks!