In index.php I have a javasript, that take JSON data from data.php every 3 sec. Data.php end with this:
echo json_encode($row);
Inspector in index.php shows a couple of objects (which are refreshed each 3 sec). Say 3 rows in DB, then it will look like this:
=>[Object, Object, Object]
I can open the above, and it looks like this:
0: Object 1: Object 2: Object
Each three can be opened again I see my newly updated data (if it change in data.php).
How do I pull out information from those objects, so I can use it live on index.php?
I should probably add the javascript that import data as well:
function populate(){
var items= [];
$.ajax({
url: 'data.php',
type: 'GET',
dataType: 'json',
success: function(data){
console.log(data);
$.each(data, function(i,v){
items.push('< th >'+v+'< /th >');
});
$('#sampleTable').html(items.join(','));
},
error: function(err){
console.log(err.responseText);
}
});
}
setInterval(function(){
populate();
},3000);