Detecting online status

Detecting online status

To instruct the user, I have used the  jqXHR.fail function in the Ajax call to do some error handling in case the server returns an error, or is not available at all (statuscode = 0).

I would like to disable the submit button, but off course it needs to be enabled again when the server is reachable again. 

Any pointers to some code snippits or pluggins that are known to work with JQM are welcome. I was thinking about iteratively trying to download something small from the server, and when that succeeds switch back to online mode again. Any ideas?

Pieter