0 Replies Latest reply on Jan 22, 2016 3:51 AM by ronald_chan

    Cordova Ajax call error response 502 always

    ronald_chan

      Dear Sir/Madam,

       

      I'm newly for JBoss, recently i'm trying to Ajax call for an access token from paypal, it is work when I export to android. However when i use in you emulator, it always response in error response status 502

       

      The code reference as follow:

      <!--  example by  https://cordova.apache.org/docs/en/3.0.0/cordova/inappbrowser/inappbrowser.html-->

       

       

      <!DOCTYPE html>

      <html>

        <head>

          <meta name="viewport" content="width=device-width, initial-scale=1">

          <link href="css/themes/1/conf-room1.min.css" rel="stylesheet" />

          <link href="css/themes/1/jquery.mobile.icons.min.css" rel="stylesheet" />

          <link href="js/jquery.mobile.structure-1.4.4.min.css" rel="stylesheet" />

          <link href="css/app.css" rel="stylesheet" />

          <script src="js/jquery-2.1.1.min.js"></script>

          <script src="js/jquery.mobile-1.4.4.min.js"></script>

          <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

       

          <script type="text/javascript" charset="utf-8">

       

          $.ajax({

              headers: {

                  "Accept": "application/json",

                  "Accept-Language": "en_US",

                  "Authorization": "Basic "+btoa("Credential:Secret")

             },

              url: "https://api.sandbox.paypal.com/v1/oauth2/token?grant_type=client_credentials",

              type: "POST",

              //data: "grant_type=client_credentials",

              success: function(data) {

                  alert("Response (paypal):");

                  alert(JSON.stringify(data));

                  $(".loader-hideOnLoad").hide();

                 // console.log("Response (data):", data);

                 // $("#out").empty().append( JSON.stringify(data, undefined, 3) );

              },

              error: function(xhr, status, error) {

       

                  alert("xhr: "+xhr.status+"; status: "+status);

              }

          });

       

       

       

       

         

       

          </script>

        </head>

        <body>

        </body>

      </html>

       

       

      Please advice how to solve it because it is trouble and slow development if every time to generate install file on mobile device.

       

      Thanks and Regards,

      Ronald Chan