test5678

You can determine that the connection is lost by making failed XHR requests.

The standard approach is to retry the request a few times. If it doesn't go through, alert the user to check the connection, and fail gracefully.

Sidenote: To put the entire application in an "offline" state may lead to a lot of error-prone work of handling state.. wireless connections may come and go, etc. So your best bet may be to just fail gracefully, preserve the data, and alert the user.. allowing them to eventually fix the connection problem if there is one, and to continue using your app with a fair amount of forgiveness.

Sidenote: You could check a reliable site like google for connectivity, but this may not be entirely useful as just trying to make your own request, because while google may be available, your own application may not be, and you're still going to have to handle your own connection problem. Trying to send a ping to google would be a good way to confirm that the internet connection itself is down, so if that information is useful to you, then it might be worth the trouble.

Sidenote: Sending a Ping could be achieved in the same way that you would make any kind of two-way ajax request, but sending a ping to google in this case would pose some challenges. First, we'd have the same cross-domain issues that are typically encountered in making ajax communications. One option is to set up a server-side proxy, wherein we actually ping google (or whatever site), and return the results of the ping to the app.. This is a catch-22, because if the internet connection is actually the problem, we won't be able to get to the server, and if the connection problem is only on our own domain, we won't be able to tell the difference. Other cross-domain techniques could be tried, for example, embedding an iframe in your page which points to google.com, and then polling the iframe for success/failure (examine the contents, etc). Embedding an image may not really tell us anything, because we need a useful response from the communication mechanism in order to draw a good conclusion about what's going on. So again, determining the state of the internet connection as a whole may be more trouble than it's worth. You'll have to weight these options out for your specific app.
Needs Translation:
Translate test5678 to Afrikaans language
Afrikaans
translated: 0%
Translate test5678 to Albanian language
Albanian
translated: 0%
Translate test5678 to Arabic language
Arabic
translated: 0%
Translate test5678 to Catalan language
Catalan
translated: 0%
Translate test5678 to Chinese Simplified language
Chinese Simplified
translated: 0%
Translate test5678 to Chinese Traditional language
Chinese Traditional
translated: 0%
Translate test5678 to Czech language
Czech
translated: 0%
Translate test5678 to Danish language
Danish
translated: 0%
Translate test5678 to Dutch language
Dutch
translated: 0%
Translate test5678 to English language
English
translated: 0%
Translate test5678 to Finnish language
Finnish
translated: 0%
Translate test5678 to French language
French
translated: 0%
Translate test5678 to German language
German
translated: 0%
Translate test5678 to Greek language
Greek
translated: 0%
Translate test5678 to Hebrew language
Hebrew
translated: 0%
Translate test5678 to Hungarian language
Hungarian
translated: 0%
Translate test5678 to Italian language
Italian
translated: 0%
Translate test5678 to Japanese language
Japanese
translated: 0%
Translate test5678 to Korean language
Korean
translated: 0%
Translate test5678 to Norwegian language
Norwegian
translated: 0%
Translate test5678 to Polish language
Polish
translated: 0%
Translate test5678 to Portuguese language
Portuguese
translated: 0%
Translate test5678 to Portuguese, Brazilian language
Portuguese, Brazilian
translated: 0%
Translate test5678 to Romanian language
Romanian
translated: 0%
Translate test5678 to Russian language
Russian
translated: 0%
Translate test5678 to Serbian (Cyrillic) language
Serbian (Cyrillic)
translated: 0%
Translate test5678 to Spanish language
Spanish
translated: 24%
Translate test5678 to Swedish language
Swedish
translated: 0%
Translate test5678 to Turkish language
Turkish
translated: 0%
Translate test5678 to Ukrainian language
Ukrainian
translated: 0%
Translate test5678 to Vietnamese language
Vietnamese
translated: 0%
Source language:


2 users participate in this project
Created: 3 years ago
Last Activity: 3 months ago