I successfully getting the data table populated if I use the sAjaxSource = "filepath/file"
However if I pass the PHP json data and try to collect it its not populating the data in the datatable,
How can I directly use the json data without calling the data from objects.txt file. ?
json_data = { "aaData": [
{
"Rendering_engine": "Trident",
"Browser": "Internet Explorer 4.0",
"Platforms": "Win 95+",
"Engine_Version": "4",
"CSS_Grade": " b"
},
{
"Rendering_engine": "rident",
"Browser": "Internet Explorer 5.0",
"Platforms": "Win 95+",
"Engine_Version": "5",
"CSS_Grade": " a"
}
] }
php code
$r = //sql query
$ma['aaData'] =$r;
$data = json_encode($ma);
var_dump($data);
script
<script>
$(document).ready(function() {
var json_data_chk = <?php echo($data); ?>;
var json_data = JSON.stringify(json_data_chk);
alert(json_data);
// code
var sImageUrl = "img/";
var oTable = $('#hidden-table-info').dataTable( {
"bProcessing": true,
"sAjaxSource": "objects.txt",
"bServerSide": false,
"aoColumns": [
{
"mDataProp": null,
"sClass": "control center",
"sDefaultContent": '<img src="'+sImageUrl+'details_open.png'+'">'
},
{ "mDataProp": "Rendering_engine" },
{ "mDataProp": "Browser" },
{ "mDataProp": "Platforms" },
],
// code
</script>
EDIT:
json_data is the variable that is having the same json data as objects.txt but instead of calling the file i want to use the data from this variable
bServerSide: trueand give the url of the ajax request tosAjaxSource. iesAjaxSource: $urljson_datais the variable that is havind the same json data as objects.txt but instead of calling the file i want to use the data from this variable