Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS JSONP$http参数“意外令牌”_Angularjs_Jsonp - Fatal编程技术网

AngularJS JSONP$http参数“意外令牌”

AngularJS JSONP$http参数“意外令牌”,angularjs,jsonp,Angularjs,Jsonp,我在AngularJS中有一个JSONP问题。它在没有必要的参数时工作,但在参数多于强制回调时返回“意外令牌”错误:JSON_回调 angular.module('myApp.controllers', []) .controller('myCtrl', function($scope, $http) { /* this works */ $http({method: 'JSONP', params:{'callback':'JSON_CALLBACK'},

我在AngularJS中有一个JSONP问题。它在没有必要的参数时工作,但在参数多于强制回调时返回“意外令牌”错误:JSON_回调

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);
    });
});

我认为错误是因为googleapi返回的是JSON而不是JSONP。您可能想重新检查他们的api以获得JSONP。谢谢,但是我在文档中找不到其他调用。我还尝试了不同的API。当我提供http参数时,总是会收到此错误消息。它不仅与谷歌API有关。