I'm testing HTML5 offline application. To do that, I'm stopping my local web server (IIS) and open application. It's loaded fine, but it failed as soon as it request server side API method.
I want to prevent that and instead of $.get('/api/method') read data from my local storage. But I can found any facility to understand my application is offline.
if (/* online */) {
// fire ajax
} else {
// ask localstorage
}
I tried to use navigation.onLine
but it seems to be always true (at least I can see that in Chrome).
Do you have any suggestions?
EDIT: taking into account current answers. Application is clearly understand that it's offline, since it takes resources according to cache.manifest. It's ridiculous to me, that client need to do any kind of tricks and pings. I assume there should be a easy way to check current mode.