ajax outsystem mobile app 

ajax outsystem mobile app 

  

Dear Team ,

 

We are trying to use below Ajax code in our mobile app we found one issue  i.e. it’s always returning ready state 0. While from other platforms(Cordova , phone gap etc ) below url working fine . is there any blockage from OutSystems to external urls http requests if so let us know how to allow/white list required urls . kindly suggest us how to fix the issue / solution . please consider we have certain scenario where we need to use Ajax only.

 Note : the url is allowed fromour network environment . 

$.ajax({

               async:true ,

               crossDomain : true,

               type:"POST",

               url:"https://stage.smartpass.government.net.ae/secure/oauth2/access_token",

               data : {

                   "grant_type": "authorization_code",

                   "code": code, 

                    "redirect_uri":"ae.gov.adm://msServices_ADM/smartpass",

                   "realm": "/TRA"

               },

               headers :  {

                   "authorization": "Basic YWRtOkMtQi1QcyRVM3c3XjhOTQ==",

                   "content-type": "application/x-www-form-urlencoded",

                   "X-SP-WEBVIEW": "1",

               }, 

                success:function (data ){

                   

                    alert('data'+data);

               },

               error : function (error ){

                   alert('error '+error );

               }

               

                });

 kindly suggest me how to achieve it .

Thanks and regards

Rajashekar Reddy Ette 

Hi Rajashekar,

I don't understand whty you have the need to use such JavaScript in a mobile app. For one, it is strongly advised against using JQuery in a mobile app. Secondly, it seems you are calling a REST service, which can be done via the OutSystems REST functionality (unless you really need to do the call from the device as opposed to the server).

Dear Kilian ,

Actually we are integrating with an SSO solution for our mobile app, in chrome custom tabs (https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller) , we are opening the SSO page in chrome custom tabs once the login successful, control will come back to  java script function , which is defined in a java script file . From there we have send back the received data to get access tokens. This is where we tried with Ajax for http post . At least can you please suggest us how we can send the received data from java script file to application so that we can avoid using ajax calls .

 



Thanks and Regards

Rajashekar Reddy Ette