我有一个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输出中出现错误
很可能他们改变了一些东西,但我想知道是否有什么东西可以帮我解决。很多帖子建议添加JSON_CALLBACK
,但我已经这样做了。关于如何解决这个问题的任何建议?