I need to warn the user with the following conditions:
- Request timed out
- No internet connection
- Unable to contact server
Here is the code; How to record the following events and warn the user?
failure: function (response) { var text = response.responseText; console.log("FAILED"); },success: function (response) { var text = response.responseText; console.log("SUCCESS"); }
I tried the following code to check if internet access is available, but it does not work.
var networkState = navigator.network.connection.type alert(states[networkState]); if (networkState == Connection.NONE){ alert('No internet '); };
UPDATE **
I added the following to my index.html, but when I turned off WIFI, I do not see a popup warning.
<script> function onDeviceReady() { document.addEventListener("offline", function() { alert("No internet connection"); }, false); } </script>
source share