0

I realize an application with which I'm supposed to send data via http with $ .getJSON.

My problem: When I test with chrome or another browser its pass but when I generate the apk and I test on a phone its does not pass.

I think that it is certainly a problem of configuration of cordova (version 6.4.0)

JS

 function jsoncallback(data){
     alert(data.service+" bien enregistré");
        $('#load').show();
            $('#imload').hide();
    }

function Service(service) {
    var var1 =$('#var1').val();
     var var2 =$('#var2').val();
   if(var1 == 0 || var2 == 0){
       alert('Service impossible.. ');
    }else{
        if(confirm("Choix : "+var1+" | "+var2)){
            $('#load').hide();
            $('#imload').show();
            $.getJSON("http://xxxx.xxxx.xx/service.php?var1="+var1+"&var2="+var2+"&jsoncallback=?");
         }
    }
}

Config.xml

<access origin="*" />
   <plugin name="cordova-plugin-whitelist" spec="1" />
   <plugin name="cordova-plugin-whitelist" version="1" />

   <allow-intent href="http://*/*" />
   <allow-intent href="https://*/*" />
   <allow-intent href="tel:*" />
   <allow-intent href="sms:*" />
   <allow-intent href="mailto:*" />
   <allow-intent href="geo:*" />
   <allow-navigation href="http://*/*" />
   <allow-navigation href="https://*/*" />
   <allow-navigation href="data:*" />

   <platform name="android">
       <allow-intent href="market:*" />
   </platform>
   <platform name="ios">
       <allow-intent href="itms:*" />
       <allow-intent href="itms-apps:*" />
   </platform>
  • [http://stackoverflow.com/questions/30060534/ajax-requests-fail-after-upgrading-to-cordova-5-0-cordova-android4-0](http://stackoverflow.com/questions/30060534/ajax-requests-fail-after-upgrading-to-cordova-5-0-cordova-android4-0) – Cisse Diafara Jan 02 '17 at 11:53

1 Answers1

2

Cordova 6.4.0 have many issues regarding plugins, ajax request and many more

There's still no fix on that issues

Many of SO users going to downgrade cordova to start working their project into it

If your code working in browser then you have to downgrade your cordova version for now.

Check issues and answers for below questions you will get more understanding on my point.

1) Cordova 6.4.0: android platfrom install Whitelist error

2) Cordova Ajax request pending for ever

Use below code to downgrade cordova version

npm uninstall -g cordova

npm install -g cordova@6.2.0
Community
  • 1
  • 1
Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56
  • @KirankumarDafa May not be true. It works for me with latest cordova version. Do you have official bugs logged to support this fact? – Gandhi Jan 09 '17 at 11:40
  • @Gandhi, `No, I haven't!` I am just suggesting to downgrade version for current projects if it was working fine before updating the latest one – Kirankumar Dafda Jan 09 '17 at 13:32
  • downgrading the version is definitely not the answer as it works fine with latest version – Gandhi Jan 09 '17 at 17:26
  • None of my downgrade suggestions accepted as an answer, i think, I have to put this in comment section, but there is no space or html format in comment section @Gandhi – Kirankumar Dafda Jan 10 '17 at 05:20