出于某种原因,当我从Flickr中提取图像时,图像不会显示,这是我到目前为止的代码。正如您所看到的,我已将其中一个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> </p>
</body>
</html>
答案 0 :(得分: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=?