突然间,我得到了一个Uncaught SyntaxError:意外的令牌:错误

时间:2015-11-13 14:25:25

标签: angularjs

我有一个Angular服务,它从themoviedb.org请求JSON输出,它总是有效,但今天我的控制台突然出现错误。

这是服务,

(function(){
  "use strict";

  angular.module('addMovieseat')

  .factory('MovieSearch',

    function($http, $q){
      return{
        search: function(searchquery){
          var deferred = $q.defer();

          var base = 'http://api.themoviedb.org/3';
          var service = '/search/movie';
          var apiKey = 'a8f7039633f2065942cd8a28d7cadad4&query='
          var search = searchquery
          var callback = 'JSON_CALLBACK'; // provided by angular.js
          var url = base + service + '?api_key=' + apiKey + search + '&callback=' + callback;


          $http.jsonp(url,{ cache: true}).
            success(function(data, status, headers, config) {

              if (status == 200) {
                deferred.resolve(data.results);

              } else {
                console.error('Error happened while getting the movie list.')
              }

            }).
            error(function (data, status, headers, config) {
              console.error('Error happened while getting the movie list.')
              deferred.resolve(false);
            });

            return deferred.promise;
        }
      }
    })

})();

这是错误,

Uncaught SyntaxError: Unexpected token :

JSON输出中出现错误

http://api.themoviedb.org/3/search/movie?api_key=a8f7039633f2065942cd8a28d7cadad4&query=James%20Bond%20Spectre&callback=angular.callbacks._2

很可能他们改变了一些东西,但我想知道是否有什么东西可以帮我解决。很多帖子建议添加JSON_CALLBACK,但我已经这样做了。关于如何解决这个问题的任何建议?

0 个答案:

没有答案