Skip to content Skip to sidebar Skip to footer

Ajax Request Works On Browser But Not On Android Device

I am making a simple mobile app with Cordova. The code I have works perfectly when I test it in a browser but it ignores the success function when test on an Android phone and prin

Solution 1:

Have you tried putting your code inside deviceready? Suppose your html starting index file look likes below,

<html><head></head><bodyonload="onBodyLoad()" ></body></html>

and your script file look likes below.

<script>functiononBodyLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}
functiononDeviceReady() {
// do your thing here!
}
</script>

Solution 2:

I made it work by building a new project with Phonegap (instead of Cordova). Exactly the same code otherwise. Still no idea why it wouldn't work with Cordova.

Post a Comment for "Ajax Request Works On Browser But Not On Android Device"