10 Replies Latest reply on Jun 21, 2016 2:07 AM by fesff86548062

    Issues with json request phonegap 3.5 to cli-5.2.0.

    fesff86548062

      Hi,

       

      before my app was in 3.5 and the request in json work fine.

      I made an update without changing the request in json and in cli-5.2.0 the request doesn't work.

       

      thanks

        • 1. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
          kerrishotts Adobe Community Professional

          You're probably running afoul of the whitelist plugin, the content-security-policy, or cross origin resource sharing. Can you share your config.xml, the HEAD portion of your index.html file, and the code where you're making the AJAX request? If there is any log in the JS or device console, sharing that would be useful too.

           

          Useful documentation:

          • 2. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
            fesff86548062 Level 1

            Hi thanks

             

            the config :

            <gap:platforms>

              <gap:platform name="android" minVersion="2.1" />

              <gap:platform name="blackberry" project="widgets"/>

              </gap:platforms>

             

             

              <preference name="phonegap-version" value="3.5.0" />

             

              <preference name="android-minSdkVersion" value="5" />

              <preference name="stay-in-webview" value="false" />

             

             

              <feature name="http://api.phonegap.com/1.0/geolocation"/>

              <feature name="http://api.phonegap.com/1.0/network"/>

              <feature name="http://api.phonegap.com/1.0/file"/>

              <feature name="http://api.phonegap.com/1.0/geolocation"/>

             

              <!--<gap:splash src="images/splash.png" width="533" height="800"/>

              <gap:splash src="images/splash_small.png" width="320" height="480" />

              <gap:splash src="images/splash-retina.png" width="640" height="960"/>-->

             

              <icon src="icon.png" />

              <icon src="icons/ios/icon.png" width="57" height="57" />

              <icon src="icons/ios/icon-72.png" gap:platform="ios" width="72" height="72" />

              <icon src="icons/ios/icon_at_2x.png" width="114" height="114" />

             

              <icon src="icons/android/ldpi.png" gap:platform="android" gap:density="ldpi" />

              <icon src="icons/android/mdpi.png" gap:platform="android" gap:density="mdpi" />

              <icon src="icons/android/hdpi.png" gap:platform="android" gap:density="hdpi" />

              <icon src="icons/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />

             

              <!--

              36px (ldpi)

              48px (mdpi)

              72px (hdpi)

              96px (xhdpi)

              -->

             

              <gap:splash src="splash.png" />

              <gap:splash src="splash/ios/Default.png" width="320" height="480" />

              <gap:splash src="splash/ios/Default_at_2x.png" width="640" height="960" />

              <gap:splash src="splash/ios/Default_iphone5.png" width="640" height="1136" />

              <gap:splash src="splash/ios/Default-Landscape.png" width="1024" height="768" />

              <gap:splash src="splash/ios/Default-Portrait.png" width="768" height="1024" />

             

              <gap:splash src="splash/android/ldpi.png" gap:platform="android" gap:density="ldpi" />

              <gap:splash src="splash/android/mdpi.png" gap:platform="android" gap:density="mdpi" />

              <gap:splash src="splash/android/hdpi.png" gap:platform="android" gap:density="hdpi" />

              <gap:splash src="splash/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />

             

             

              <!--

              ldpi: small screens are at least 426dp x 320dp

              mdpi: normal screens are at least 470dp x 320dp

              hdpi: large screens are at least 640dp x 480dp

              xlarge screens are at least 960dp x 720dp

              -->

              <preference name="detect-data-types" value="false" />

              <preference name="splash-screen-duration" value="7000" />

             

             

              <access origin="*" />

              <preference name="disable-cursor" value="true" />

              <preference name="target-device" value="universal" />

             

            the head :

             

            <link href="jquery-mobile/jquery.mobile-1.3.1.min.css" rel="stylesheet" type="text/css"/>

            <link href="css/style.css" rel="stylesheet" type="text/css"/>

            <script src="jquery-mobile/jquery-1.9.1.min.js" type="text/javascript"></script>

            <script src="jquery-mobile/jquery.mobile-1.3.1.min.js" type="text/javascript"></script>

            <script src="phonegap.js"></script>

            <script>

            $( document ).bind( "mobileinit", function() {

                $.mobile.allowCrossDomainPages = true;

              $.support.cors = true;

            });

             

            and the json request:

             

            $.ajax({

              url: '************,

              dataType: 'jsonp',

              jsonp: 'jsoncallback',

              timeout: 5000,

              success: function(data, status){

              output.empty();

              if (data.length == 0) {

              output.append("<p style='text-align:center; font-size:18px; margin-top:20px;'>Pas de résultat</p>");

              output.listview("refresh");

              }

              $.each(data, function(i,item){

             

              var donnee =  '<li><a href="fiche.html?identifiant='+item.id+'&cat='+cat+'" rel="external" data-transition="slide" data-icon="arrow-r" data-iconpos="right" >'+stripslashes(item.RAISONSOCIALE)+'<p class="subItem"><span style="color:#000; font-size:9px;" >'+stripslashes(item.VILLE)+'</span></p></a></li>';

              output.append(donnee);

              output.listview("refresh");

              });

              },

              error: function(request, error){

             

              output.text('Problème avec les données.');

              //output.append('Problème avec les données.');

              //output.text(request.responseText);

              //errors.append("<li>"+error.message+" Problème avec les données: "+statement+"</li>");

              }

              });

            • 3. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
              kerrishotts Adobe Community Professional

              "<preference name="phonegap-version" value="3.5.0" />" implies that you're still using the 3.5.0 version of PhoneGap Build., not 5.2.0. Is this the config.xml that is working or that is failing?

               

              Also, when moving to 5.2.0, you will need to add the whitelist plugin and configure a content-security-policy (see links in my prior post). Also, any particular reason you're going to 5.2.0 and not 6?

               

              I also see that you've got an an error handler -- are any of the error messages being rendered? If so, you'll want as much information as possible (not just a generic message), so I'd include things like error message and the request status and the like.

              • 4. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                fesff86548062 Level 1

                thanks it's was because I rollback to see if it's working in 3.5. It's working in 3.5

                Ok i didn't know the whitelist.

                The build say me upgrade to 5.2 I didn't know the 6!

                Can you explain more please for the error handler? thanks a lot

                • 5. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                  kerrishotts Adobe Community Professional

                  You can follow the PhoneGap Build blog to stay up-to-date with what's available.

                   

                  Regarding the error handler -- you've got a line that renders "Problème avec les données" -- does that line actually appear in your app when the AJAX request fails? If so, it's very generic, and so I'd suggest including "error.message" and "request.status" to see what else is going on with the error condition. [Perhaps even just "JSON.stringify(request,null,2)" to see all the properties in the request object.]

                  1 person found this helpful
                  • 6. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                    fesff86548062 Level 1

                    thanks a lot for the advice!

                    I try your improvement 

                    • 7. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                      fesff86548062 Level 1

                      The package doesn't open in 6

                      I try in 5 but a simple link doesn't work my config have

                      <allow-intent href="http://*/*" />

                      <allow-intent href="https://*/*" />

                      <allow-navigation href="http://*/*" />

                      <allow-navigation href="https://*/*" />

                      • 8. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                        kerrishotts Adobe Community Professional

                        Can you post what your link looks like / any code you're using to create the link?

                        • 9. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                          fesff86548062 Level 1

                          the link is

                          <a href="http://www.google.com" data-role="button" rel="external" target="_blank">Link</a>

                          the others with json have an output error: timeout

                           

                          thanks

                          • 10. Re: Issues with json request phonegap 3.5 to cli-5.2.0.
                            fesff86548062 Level 1

                            Hi,

                             

                            do you have an idea?

                            thanks