In my Phonegap based hybrid app: Ajax calls start failing if my app is inactive for say a couple of minutes. My connection is WiFi & what happens is ajax calls fail with status 0; but navigator.connection.type still shows WiFi. This happens only on iOS not on android.
Then I i noticed if the user keeps clicking around the app (thus initiating ajax calls which actually keep failing with status 0), he is able to bring the app back on track after say 2 minutes (i.e. suddenly the ajax calls start working and post that the app works perfectly fine). Seeing this behavior I created a loop that executes on failure every 5 seconds until finally the app is able to connect i.e. successfully execute ajax call after 2 minutes. (This is not feasible since no user will wait for 2 minutes for the app to connect back)
Other option i tried was to set the key UIRequiresPersistentWiFi in iOS property list file to YES (but this did not resolve the issue)
I can also see the WiFi icon with full signal strength, Other Apps like facebook etc. work fine using the WiFi.
I have really broken my head for the last couple of hours around this and i have no clue where and how to troubleshoot this. Any help is much appreciated. Thanks!