4
Does anyone know a good function or a good way to check if there is an internet connection before making an ajax request?
4
Does anyone know a good function or a good way to check if there is an internet connection before making an ajax request?
6
It’s possible, try to:
var online = navigator.onLine; // true ou false, (há, não há conexão à internet)
if(online) {
// efetuar pedido ajax
}
To test, create a file on your computer, e.g., online.html and type:
<script>
var online = navigator.onLine;
alert(online);
</script>
Open it in the browser and turn the connection off/on to test
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.