whiteyalrighty whiteyalrighty - 15 days ago 5
jQuery Question

Android debuggable=false causing jQuery.ajax POST to fail in Cordova/Phonegap Eclipse project

I have an Android app built in Eclipse which uses Cordova 2.0.0. When built and loaded onto the phone using the Eclipse debugger the app works fine, but when I set android:debuggable="false" in the AndroidManifest file the jQuery.ajax() POST fails. I get nothing to tell me the failure reason in the LogCat trace.

Here's the jQuery.ajax call:

jQuery.ajax({
url: that.endpoint,
data: that.data,
dataType: "json",
type: "POST",
contentType: "application/json",
success: successHandler,
error: errorHandler,
timeout: serviceTimeout
});


When android:debuggable="true" it works fine and goes to the success handler, but when it android:debuggable="false" it goes to the failureHandler, with only textStatus set to "error" and nothing else to indicate why it failed. When it fails it appears that the post doesn't happen because I can see that it doesn't hit the webservice I am trying to call.

Does anyone have any ideas why the debuggable flag might be affecting my application in this way?

What else other than the logging level would the "debuggable" flag affect?

Any hints or pointers would be greatly appreciated.

Cheers

Answer

Found the reason for this. My code was fine. The problem was with the SSL certificate of the webservice I was trying to call. Although my browser said it was ok, when I checked it with an SSL certificate checker (http://www.geocerts.com/ssl_checker for example) it showed me there was an issue with a certificate hierarchy. Fixing the certificate allowed my code to work.

I never had this problem with the iPhone version of the app so it seems that Android is more strict with it's SSL certificate checking (and it does no certificate checking when running in debug mode.)

Comments