AngularJS JSONP SyntaxError: Unexpected token :

三世轮回 提交于 2019-12-25 04:45:25

问题


I am trying to use the WordsAPI and everytime I try to access it using jsnop and Angular I get this error:

The code I am using is the following:

  $scope.searchWord = function() {
var url = 'https://www.wordsapi.com/words/'+$scope.word+'/definitions?callback=JSON_CALLBACK&accessToken=ACCESS_TOKEN';
$http.jsonp(url).
success(function(data, status, headers, config) {
  $scope.meanings = data;
  console.log($scope.meanings)
}).error(function(data, status, headers, config) {
  console.log(data);
});

}

So it should be getting something like: https://www.wordsapi.com/words/word/definitions?callback=JSON_CALLBACK&accessToken=ACCESS_TOKEN

I tested this link on JSON validators and everything is fine with the JSON it gets from the server. I am using Chrome on a Mac.

Does Anyone have any idea ?

来源:https://stackoverflow.com/questions/27848003/angularjs-jsonp-syntaxerror-unexpected-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!