Software Archive
Read-only legacy content
17061 Discussions

Ajax call blocked when installed on Android

Remi_I_
Beginner
420 Views

I'm trying to get my AJAX call working on the installed app.

When testing on the emulator it works fine and also works in the test tab however when I have uploaded the APK file to android and it have been uploaded onto the App Store the AJAX call does not work?

Not sure why I have also for the whitelist I have selected Cordova Android Whitelist,

The screenshot is below.

0 Kudos
4 Replies
PaulF_IntelCorp
Employee
420 Views

Update jQuery to version 2 and check this FAQ, might help > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail <

0 Kudos
Marv_Y_
Beginner
420 Views

Hello,

My attempt is to do a $.ajax(url:'url',type: 'GET' from a remote website

My Build: IntelXDK 3491

CLI: 5.4.1

Target Device:Android

I have noted the recommendation relative to jQuery upgrade here:
 https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail

I am Currently using Jquery 2.2

I've experienced similar hurdle related to $.ajax calls---The result/return from the call always results in a

'readyState=1' for the return object, but no data is returned, nor is a return status logged; The domain

of the url, as well as wildcards for the subdomain  are whitelisted in my build settings; (Please note that i've

attempted the call using both the 'success' and 'complete' events of the $.ajax event list;

The  return status is never logged . If i set breakpoints corresponding to occurrences of the console.log items for

status, returnno, etc., these breakpoints are skipped.

  -If i step through the code, the result bypasses any attempt to log a return status. The

conditional check using '(IsDebug() && client!==null) is stepped into,client.toString()

is display simply as [object Object],. The enclosed screenshots lend further detail to

the content of client at the occurrence of '(IsDebug.....

 

I've attempted to use the snippet shown below, as well as one where no DOMParser is used to

handle returned data;

Here is the code snippet where I make the call:

var client={};

try{ 

client=$.ajax({
            url:'https://www.powerfocus.biz/user/powerfocusbasic3so/c/gclient_UnAuthUser.xml',
            type:'GET',
            dataType:'xml',
            error:function(xhr,textStatus,errorThrown){
                console.log("error reported: " + ':' + (errorThrown?errorThrown:'Unknown') + 'state:' + textStatus);
            },
            complete:function(xhr,textStatus){
                client = new DOMParser().parseXML(xhr.httpResponse.data);
                 return client.toString();
            }
            }).always(function (retorno, textStatus, jqXHR) { //;paf; see http://stackoverflow.com/a/19498463/2914328
                 console.log("jQuery version: " + $.fn.jquery) ;
                 console.log("arg1:", retorno) ;
                 console.log("arg2:", textStatus) ;
                 console.log("arg3:", jqXHR) ;
               if(retorno.status==200
                  || retorno.status > 200
                  || retorno.responseJSON!==null)
                   {
                       console.log(retorno.status);
                       console.log(JSON.stringify(retorno.responseJSON));
                   }
            });
                 
        if(IsDebug()
          && client!==null)
            {
                
                alert("String raw string value: " + client.toString());
                
            }      

}catch(err){

console.log(err.message)

}

return client;

}

 

0 Kudos
Marv_Y_
Beginner
420 Views

Regarding post: My target build is Android OS;

 

0 Kudos
PaulF_IntelCorp
Employee
420 Views

Marv -- are you doing this testing in the Simulate tab or in a built app or from the Debug tab or within App Preview? You will get different results in each of those environments. To test this thoroughly on a real device with a built app (which is, obviously, the most accurate condition), use the technique outlined here > https://software.intel.com/en-us/xdk/docs/intel-xdk-debug-and-test-overview#RemoteChromeDevTools <

0 Kudos
Reply