我只是想使用 angularjs http 对 itunes 搜索 api 进行基本调用。
$http.jsonp("http://itunes.apple.com/search", {params:{"term":"jack+johnson"}})
.success(function (data, status, headers, config) {
console.log("is scope : " + data);
}).error(function (data, status, headers, config) {
console.log("error" + status);
});
请求做得很好(状态:200),我可以看到 json 被检索,这是一个摘录:
{
"resultCount":50,
"results": [
{"wrapperType":"track", "kind":"song", "artistId":909253, "collectionId":120954021, "trackId":120954025, "artistName":"Jack Johnson", "collectionName":"Sing-a-Longs and Lullabies for the Film Curious George", "trackName":"Upside Down", "collectionCensoredName":"Sing-a- Longs and Lullabies for the Film Curious George", "trackCensoredName":"Upside Down", "artistViewUrl":"https://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4", "collectionViewUrl":"https://itunes.apple.com/us/album/upside-down/id120954021? i=120954025&uo=4", "trackViewUrl":"https://itunes.apple.com/us/album/upside-down/id120954021? i=120954025&uo=4", ....
但是我在 json 结果的第一行(“resultCount”:50)有一个 js 错误:“Uncaught SyntaxError: Unexpected token:”。
我尝试使用 transformResponse 但错误发生在之前。
谢谢