So basically here is my script, which is in index.php –
<script type="text/javascript">
setInterval(function() {
jQuery.ajax({
url: "ajaxChecker.php",
context: document.body
}).done(function(response) {
if(response == true) {
location.reload(true);
}
});
}, 1000 * 60);
</script>
It should each minute send request to balanceChecker.php for receiving data, and then check wether it’s true reload page otherwise do nothing.
Here is ajaxChecker.php file
<?php
return true;
?>
but it doesn’t work. Any ideas?
EDITED the AJAX Part, doesn’t work now also –
setInterval(function() {
jQuery.ajax({
url: "ajaxChecker.php",
context: document.body,
success: function(response) {
if(response == "true") {
location.reload(true);
}
}
});
}, 1000 * 10);
and in ajaxChecker.php file replaced return to echo and true to “true”.
You doesn’t output anything by your php.
Should be:
and in js:
Also I would reccomend to not include PHP closing tag:
?>to avoid unnecessary new lines and to prevent sending header info: