Please dont mind syntax errors, this is just a gist for the whole code
I got this webpage with the JS code below:
setInterval(function(){
$.ajax({
url: my_page.php,
dataType: 'json',
success: function(data){
console.log(data.key);
}
});
}, 1000);
And my_page.php looks like this:
include database.php
$data = mysql_fetch_array(mysql_query("valid SELECT query"), MYSQL_ASSOC);
echo json_encode($data);
(Chrome) console shows this:
correct_result
null
null
...
Can anybody explain why? I have tested the query and is 100% correct, it echoes the correct result on first iteration anyway.
Thanks!