【发布时间】:2014-07-10 08:26:06
【问题描述】:
我使用 flickr 照片搜索方法来检索公共照片。 当我用 jquery 运行它时,它工作正常,我得到了正确格式的 json 对象。
{
"photos": {
"photo": [
{
.........
}
]
},
"stat": "ok"
}
但是当我将它与 AngularJs 一起使用时,我得到了带有前缀 jsonFlickrApi 的相同对象
jsonFlickrApi({
"photos": {
"photo": [
{
......
}
]
},
"stat": "ok"
})
我在 AngularJs 中使用的是:
myApp.service('dataService', function($http) {
delete $http.defaults.headers.common['X-Requested-With'];
this.flickrPhotoSearch = function() {
return $http({
method: 'GET',
url: 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=3f807259749363aaa29c2fa93945&tags=india&format=json&callback=?',
dataType: 'json'
});
}
});
请告诉我如何将第二个 JSON 转换为第一个。
我可以在$http 调用中做些什么或者必须更改 JSON 对象。
【问题讨论】:
标签: javascript jquery json angularjs flickr