<script>
function ajaxQuery () {
$("div#loading").html('<img src="********/loading.gif">');
$.post('https://*****.php', {test: 'test'}, function (data) {
if (data == 'yes') {
$("div#loading").html('Yes. ');
clearInterval(aInterval);
} else if (data == 'no') {$("div#loading").html('No.');
clearInterval(aInterval);}
else if (data == 'wait'){}
});
}
var aInterval = setInterval(ajaxQuery, 5000);
</script>