Search code examples
androidjquerycordovaapkgetjson

getJSON doesn't work on phonegap build


I want to make getJSON with an apk builded with phonegap. My function work on desktop but when i run it from the apk, the function is not executed.

My jQuery function:

$.getJSON( url, function( data ) {
      var items = [];
        if (data.state == 'ok'){
            $('#succes').html("Votre compte a été créé");
        }
        else { 
            $('#succes').hide();
            $('#erreur').html("Une erreur est survenue !");
            $('#erreur').fadeIn();
        }
    });

I have already add this on my config.xml

<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="*" />

Thanks you for your help ;)

(and sorry for my english level)


Solution

  • It looks that you are missing the white-list plugin:

        <access origin="*"/>
        <!-- Added the following intents to support the removal of whitelist code from base cordova to a plugin -->
        <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
        <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:*" />