【问题标题】:Trying to display images in HTML with Flickr API尝试使用 Flickr API 以 HTML 格式显示图像
【发布时间】:2014-03-31 10:53:34
【问题描述】:

由于某种原因,当我从 Flickr 中提取图像时,图像不会显示,这是我目前拥有的代码。如您所见,我已将其中一个 URL 注释掉,注释掉的 URL 实际上可以工作并显示图像,但它之前的 URL(我实际需要的 URL)不起作用。

<!DOCTYPE html>
<html>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<script src="http://ajax.googleapis.com/ajax/li`enter code here`bs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> 
<script type="text/javascript">
$(document).ready(function () {
    $.getJSON("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=bde2ddde05dd5e7abbc7a44b9abc12ef&tags=gtav%2C+grand+theft+auto%2C++rockstar&bbox=-122.65057757118905%2C37.71174524790033%2C-122.2214241288068%2C37.81705186562751+&has_geo=&format=json&nojsoncallback=?", displayImages1); <!--("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=bde2ddde05dd5e7abbc7a44b9abc12ef&tags=gtav&format=json&jsoncallback=?", displayImages1); -->    
    function displayImages1(data) {

        $.each(data.photos.photo, function (i, item) {

            var photoID = item.id;

            lat = item.latitude;
            long = item.longitude;

            $('#images1').append(photoID);

            var photoURL = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_m.jpg';

            htmlString = '<img src="' + photoURL + '">';

            $('#images1').append(htmlString);

            $('#images1').append("<br/><hr/><br/>");



        });
    }
});
</script> 


</head>
<body>
<div id="images1"> </div>
<p>&nbsp;</p>

</body>        
</html>

【问题讨论】:

    标签: javascript html json flickr


    【解决方案1】:

    您的链接不正确。正确的链接如下。它以 jsoncallback 结束。

    http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=bde2ddde05dd5e7abbc7a44b9abc12ef&tags=gtav%2C+grand+theft+auto%2C++rockstar&bbox=-122.65057757118905%2C37.71174524790033%2C-122.2214241288068%2C37.81705186562751+&format=json&jsoncallback=?
    

    【讨论】:

    • 干杯有效。我以为我自己试过了,一定错过了什么,谢谢。
    猜你喜欢
    • 2011-09-23
    • 2015-09-30
    • 2014-04-07
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多