Question

I am trying to do request cross domain using phonegap/cordova v2.4 in Kindle Fire. I am also using jquery/jquery mobile for the test case. I have had no issues in the past with android devices but when I migrated to Kindle, I cant seem to get the requests to work. My very Simple JS

function deviceInfo(){

alert('hi');
$.ajax({
  url: "URL",
  dataType: 'jsonp',
  crossDomain:true,
  success: function(suc){
      alert('suc');
  },
  failure:function(msg){
      alert('msg');
  }
});}
$(function() {
document.addEventListener("deviceready", deviceInfo, true);
});

My config file for phonegap has the following

<access origin="*" />
<access origin=".*"/>
<access origin="http://127.0.0.1*" />
<access origin="http://localhost:65198*" />

I have tried multiple variations to try to get it to allow any url but cross domain still seems to be an issue. I can test it locally in a web browser and it works fine. I have also tried using a local and remote server and neither work in the app but fine in the browser.

Also tried phonegap jQuery .ajax cross domain requests work in browser, fail in Android SDK And I have these permissions

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Was it helpful?

Solution

I was able to get this to work. Definitely user error in this case. The wifi connection was trying to use a couple of the business's next door wifi. It first used one that was open and it updated some of the devices apps which gave the impression that it was connected. Then it lost the signal and tried to switch to a wifi that was protected through a url instead of having a wifi password so it ended up saying its connected but unable to actually process any requests. After I switched to using my own wifi, everything ran smoothly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top