In all honestly I'm not sure whether you can with a web app; I mean query whether there is an active and live connection. Though using javascript you should be able to discover whether there is.
Just to deviate slightly, with a native app you would listen for a success response when you post something to the server - so the server talks to the app; if there is no server response then you know the server is unavailable. You wouldn't just check for a data connection to be live as that can be unreliable; you need a success response.
You need to check that the transfer can and has been made. Remember if someone is on the move they could have a connection but it could be so poor that it is unreliable. In which case it might make sense to store the data.
You could do something similar to that with javascript; so use javascript (jQuery/AJAX) to connect to the server side script and wait for the reply, if it times out; then take an alternative action.
With saving the data, with native apps and web apps you can access local storage; using HTML 5:
http://paperkilledrock.com/2010/05/h...rage-part-one/
Bookmarks