I created a phonegap app project where I withdraw informations from my server, in JSON. With JS I can transform them in object.
But now I want to know with cordova if there is or not an internet connection, to proceed or not with the xmlhttprequest.
How can I do?
In addition to Chris W. Griffith 's correct answer, let me add one more thing:
Do not make the assumption that because you're attached to a network (say WIFI or even Cellular) that you have a route to your host. If `navigator.connection.type` reports anything other than `Connection.NONE`, you must make the attempt to contact your host, and appropriately handle any errors that may occur due to the lack of a route. (Great example: hotel WIFI where you have to login before you can get out of the network)