2016-12-26 66 views
0

我想在我的android应用程序中返回一个jsonp发出一个跨域请求。Ajax在Android应用程序调用

$('#loader-message').text("Please wait while we retrieve the inventory status"); 
$.ajax({ 
     type:'GET', 
     url: 'myUrl', 
     dataType: 'jsonp', 
     success: function(data) { 
     console.log(data); 
     }, 
     error: function(data) { 
     console.log("error"); 
     } 
    }); 

现在,当我在浏览器中运行它时,它工作正常。

的问题是在我的模拟器/实际的应用程序,它只是显示我加载消息如上“请稍候,我们检索库存状态”

现在的问题是“是Ajax调用是至少做了?“ 如果没有,那么我该如何解决这个问题?

回答

0

我通过使用离子角来解决我的上述问题。

var exampleApp = angular.module('starter', ['ionic'])  
exampleApp.controller('ExampleController', function($scope, $http) { 
    $scope.getData = function() { 
      $http.get("myUrl", { params: { "key1": "value1", "key2": "value2" } }) 
      .success(function(data) {     
      }) 
      .error(function(data) {     
      });   
    }}); 
相关问题