After your comments I can obtain them in the following way:
<?php
header('Content-type:application/json;charset=utf-8');
$id = $_POST['id'];
$packing = PackingListData::getPackingList($id);
$arr = array();
foreach ($packing as $pack) {
$arr[] = array(
"data"=>array(
'id'=>$pack->id,
'referencia' =>$pack->referencia,
'estilo'=>$pack->estilo,
'bultos'=>$pack->bultos,
)
);
}
echo json_encode($arr);
?>
Here it shows in my console.log (data):
And my function js where I try to show that data:
function obtenerPacking(id){
$.post("index.php?action=getPackingList",{id:id},function(data){
console.log(data);
var table = $("#tblListado").DataTable({
"ajax":{
"method":"POST",
"dataType":"json"
"url";""
},
"colums":[
{"data":"id"},
{"data":"referencia"},
{"data":"estilo"},
{"data":"bultos"},
]
});
})
}
and it generates a conflict from $ .post with my url, how can I add my argument.