【问题标题】:Issues retrieving jsonp with $http.jsonp使用 $http.jsonp 检索 jsonp 的问题
【发布时间】:2014-11-01 14:38:27
【问题描述】:

代码:

当我通过浏览器中的 url 时,当我尝试打开它时,我可以看到所有对象,例如: link

但我似乎无法让它在我的代码中工作我错过了什么吗?

 angular.module('ionicApp', ['ionic'])

 .controller('MyCtrl', function($scope, $http) {

  $scope.items = [];



  $http.jsonp('cmaden.pythonanywhere.com/api/v1/today/?format=jsonp').success(function    (data) {
    $scope.items = data;

});

});

【问题讨论】:

    标签: javascript json ionic-framework application-icon


    【解决方案1】:

    在网址前面添加“https://”。您还需要回调。请看下面的例子。

    angular.module('ionicApp', ['ionic'])
     .controller('MyCtrl', function($scope, $http) {
     window.callback = function(data) {
          $scope.items = data
        }  
      $scope.items = [];
     $http.jsonp('https://cmaden.pythonanywhere.com/api/v1/today/?format=jsonp');  
    });
    

    【讨论】:

      猜你喜欢
      • 2015-08-27
      • 2019-05-29
      • 2011-07-12
      • 1970-01-01
      • 2015-06-09
      • 1970-01-01
      • 2016-05-02
      • 1970-01-01
      • 2013-09-12
      相关资源
      最近更新 更多