2 Replies Latest reply on Feb 11, 2017 1:24 PM by leonardok45048449

    Ajax readyState 4 status 404 statustext error

    leonardok45048449

      I am having a problem to perform an Ajax request

       

      Already installed the cordova-plugin-whitelist and problem persist.., I'm building on Phonegap Build, tested on BlueStacks 2(simulator) and Moto E Android 5.1

       

      My config.xml

       

          <plugin name="cordova-plugin-whitelist" spec="1.3.1" />

          <plugin name="phonegap-plugin-barcodescanner" spec="6.0.5" />

          <plugin name="cordova-sqlite-evcore-extbuild-free" spec="0.8.5" />

          <preference name="android-build-tool" value="gradle" />

          <access origin="http://*" />

          <access origin="https://*" />

          <allow-navigation href="*" />

          <allow-intent href="*" />

       

      Ajax inside the callback function 'deviceready' works, but anothers ajax requests don't.

      Error: {"readyState":4, "status": 404, "statusText":"error"}

       

      var app = {

          initialize: function() {

              this.bindEvents();

          },

          bindEvents: function() {

              document.addEventListener('deviceready', this.onDeviceReady, false);

          },

          onDeviceReady: function() {

            $.ajax({

                dataType:'jsonp',

                ....

              WORKS.

            });

              app.anotherFunction();

          },

           anotherFunction: function() {

             $.ajax({

              DON'T WORK.

            });

           }     

      };