jquery - Checking internet connection using JavaScript -
problem
I want to show a warning that the Wi-Fi is off [I.e. no internet connection] In my webpage, I have lots of buttons, pop-ups, etc. Users can click on anything when offline. But I want to show that there is a failure in the API call or not. I can check navigator.online in each click. But I do not want to type the function calls or the number of lines, is this a normal way to use jQuery, JS, Ajax?
"The alert should be shown when the call failed, which is caused by a user's action"
such as
$ Ajax with any error Should not be bound by the device / page.
Hello, I have made the following efforts:
Navigator.online // It works fine I used it as described below but it is not working
. & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script & gt; & Lt; Script & gt; Window.jquire || Document.write ('& quot; script src = "js / vendor / jquery-1.10.2.min.js" & gt; & lt; / script & gt;') & lt; / Script & gt; I have written the references
and something else
Any suggestions?
You can use the original setInterval function here, for example, Use a set interval in your function inside the document.ready function, or perhaps it is more ubiquitous when the page loads:
setInterval (callbackFunction :, 1000 / * and lieutenant; - Function in every interval MS * /); and callbackFunction = function on your callback funciton (probably setInteraval above):
If (navigator.oline) {// manipulate dom}}; It's manipulating the dom, and also that the callback function, if defined outside of document.ready () function. Remember to give > SetIntern () Greetings, probably should be declared first.
Comments
Post a Comment