AngularJS JSONP $ http params'意外的标记''

时间:2014-05-01 21:15:46

标签: angularjs jsonp

我在AngularJS中遇到了JSONP问题。当没有必要的参数时它会工作,但只要有比参数强制的“回调:JSON_CALLBACK”更多的参数,就会返回“意外的令牌”错误

angular.module('myApp.controllers', [])
.controller('myCtrl', function($scope, $http) {

/* this works */
$http({method: 'JSONP', 
          params:{'callback':'JSON_CALLBACK'}, 
          url: 'https://graph.facebook.com/paris'}).success(function(data) {
              $scope.fbchannel = data

           }).error(function(err) {
                 console.log(err);
          });

/* this works not: Uncaught SyntaxError: Unexpected token :  */
     $http({method: 'JSONP', 
            params:{'callback':'JSON_CALLBACK', 'address':'Paris', 'sensor':'false'},                               
    url: 'http://maps.googleapis.com/maps/api/geocode/json'}).success(function(data) {
              $scope.gmaps = data

    }).error(function(err) {
          console.log(err);
    });
});

0 个答案:

没有答案
相关问题