So I'm juste trying to create a counter which update a value in my database everytime I click on a button and then I would like to display this value on the page. My code to update the value is working, but my code to display the value doesn't want to work.
Here is my js code to refresh the counter :
<script>
setInterval("checkCount()",500);
function checkCount()
{
jQuery.ajax({
url: 'http://ntc.aiesecfrance.org/server_count_get/',
dataType: 'json',
success: function(data) {
alert("data.count");
}
});
};
</script>
and here is my php code to get the value from the database.
$connection = mysqli_connect("localhost", "test", "", "test");
if (mysqli_connect_errno()) {
echo 'connection failed';
}
// Fetching the value
$query = "SELECT count FROM counterval WHERE id=1";
$count = mysqli_query($connection,$query);
$value = mysqli_fetch_array($count);
header('Content-type: application/json');
echo json_encode($value);
?>
but with this I got no alert. It just doesn't show up. Here is an example of what is retunrned by the php :
{"0":"8","count":"8"}
Thanks in advance for your help.