I'm trying to set up a display screen for the floor info which is a simple web page. The ajax call is for updating the screen every 10 seconds according to the admin page which the client is using for updating the info.
My problem is when there is no internet connection, the display would still be updated and shows nothing. Is there any way I can alter the code below to say if there is an internet connection then update the database, if there no network connection then reset the timer and do nothing.
<script type="text/javascript">
// Run the AJAX call to grab the data once
$.ajax({
type: "POST",
url: "ajax/getMessages.php?section=1",
data: "",
complete: function(data){
//print result in targetDiv
$('#content_1').html(data.responseText);
}
});
// Then run the same script on a 10-second timer
setInterval(function(){
$.ajax({
type: "POST",
url: "ajax/getMessages.php?section=1",
data: "",
complete: function(data){
//print result in targetDiv
$('#content_1').html(data.responseText);
}
});
},10000);
</script>