Search code examples
androidangularjsajaxintel-xdk

AJAX call not getting information on Intel XDK


I'm building an APK for the blood bank of my local city and i need to get the stock of blood by groups, i have some JSON that i test with Postman that woks but i need to add them to my Intel XDK project. I have follow some examples with AJAX and HTTP but with no result.

 ionic.Platform.ready(function(){
 $("#ajax").click(function(){        
            $.ajax({
                method: 'GET',
                url: 'http://192.168.1.100/api/hospital/17659861-1',
                dataType: 'json',
                success: function (data) {
                    alert('Data RecibidaAPI: ' + data);
                    console.log(data.data[0].us_rut);
                    console.log(data.data[0].us_nombre);
                    console.log(data.data[0].us_telefono);
                    console.log(data.data[0].us_id_dispositivo);
                    console.log(data.data[0].us_grupo_sangre);
                }
            }).then(function (data) {
                console.log('Data RecibidaAPI: ' + data);
            });
        });

}

and also try

<div id="campa_de_sangre" class="upage-content vertical-col left hidden" ng-app="myApp2" ng-controller="myCtrl2">
<p>hola</p>
            <h1>{{myWelcome}}</h1>
            <p>Status : {{statuscode}}</p>
            <p>StatusText : {{statustext}}</p
            <p>{{content}}</p>
<script>
var app2 = angular.module('myApp2', []);
app2.controller('myCtrl2', function($scope, $http) {
  $http({
    method : "GET",
    url : "welcome.htm"
  }).then(function mySucces(response) {
      $scope.myWelcome = response.data;
      $scope.statuscode = response.status;
      $scope.statustext = response.statusText;   
    }, function myError(response) {
      $scope.content = "Something went wrong";

  });
});
</script>
</div>

where i could't even get the scope.satuscode to work. I'm using Ionic as framework with AngularJS, if someone need extra info to helpmeet just ask and thanks for any idea.


Solution

  • See this FAQ on the Intel XDK web site > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail