使用的getJSON访问Flickr的数据 [英] Using getJSON to access Flickr data

查看:108
本文介绍了使用的getJSON访问Flickr的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问JSON数据该用户并使用该code写的人的ID:

I'm trying to access the JSON data for this user and write the id of the person using this code:

   <!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript">
API_KEY = 'YOUR_API_KEY';

$.getJSON('https://www.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=' + API_KEY + '&user_id=22694125@N02&format=json&jsoncallback=?', function(results){
      document.body.innerHTML = JSON.stringify(results.photos.photo[6].id);
  });</script>

</head>
<body>

</body>
</html>

由于某种原因,它不会返回任何东西。帮助?

For some reason, it doesn't return anything. Help?

推荐答案

根据我读过,我认为你需要像这样:

Based on what I've read I think you need to something like this:

$.ajax(
{
    url: "https://www.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=[APIKEY]&user_id=22694125@N02&format=json&jsoncallback=?",
    type: "GET",
    cache: true,
    dataType: 'jsonp',
    success: function(data) 
    {
        console.log(data);
    }
});

我相信调用必须JSONP(JSON没有)。

I believe the calls have to be JSONP (not JSON).

这篇关于使用的getJSON访问Flickr的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆