Datatables And Ajax Data Formatting?
I am using Datatables and I want to be able to send an AJAX request to get my data. My jQuery - $('.valid-tags').DataTable( { 'ajax': { 'url': '/ajax/getValidTags.php'
Solution 1:
Change the format of the JSON that you're returning as shown below. See Data source types for more information.
{
"data": [
[ "K", 2 ],
[ "B", 1 ],
[ "C", 2 ]
]
}
Change your initialization options as shown below.
$('.valid-tags').DataTable( {
"ajax": {
"url": "/ajax/getValidTags.php",
"type": "POST",
"data": {
ruleID: ruleID
}
},
"columnDefs": [{
"targets": 2,
"render": function(data, type, full, meta){
return '<button type="button">Manage</button>';
}
}]
} );
See this jsFiddle for code and demonstration.
Post a Comment for "Datatables And Ajax Data Formatting?"