Flickr.photos.search()错误(GAE + JSF)

时间:2017-01-15 22:39:53

标签: ajax google-app-engine flickr

我的问题是愚蠢的问题,我试图通过使用标签来显示来自flickr的一些图像。当我部署应用程序时,我得到一个空白页面。但通过检查浏览器的控制台,我发现了这个:

(index):13
Uncaught SyntaxError: Invalid or unexpected token?method=flickr.photos.search&api_key=88f1c84…&tags=football&per_page=5&page…:1

 Uncaught ReferenceError: jsonFlickrApi is not defined at ?method=flickr.photos.search&api_key=88f1c84…&tags=football&per_page=5&page…:1

我真的不知道这意味着什么......

<!DOCTYPE html >


<html>
<head>
<TITLE>Flickr</TITLE>

</head>
<body>

<script>
function jsonFlickrApi(rsp){
    window.rsp = rsp;
    var s = "";
    s = "total number is: "+rsp.photos.photo.length+"<br/>";

    for(var i=0;i&lt;rsp.photos.photo.length;i++){
        photo = rsp.photos.photo[i];
        t_url = "http://farm"+photo.farm+".static.flickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+"_"+"t.jpg";
        p_url = "http://www.flickr.com/photos/"+photo.owner+"/"+photo.id;
        s += '<a href="' + p_url+ '">' + 'img alt="'+photo.title+ '"src="'+t_url+'"/>'+'</a>';

    }
    document.writeln(s);
}   
</script>

<script src="https://api.flickr.com/services/rest/?method=flickr.photos.search&#38;api_key=88f1c841c5e9acb6cccd8f1f81cf6950&#38;tags=football&#38;per_page=5&#38;page=1&#38;format=json&#38;api_sig=70c1245d615fa1dc6b254724dcbabfad"></script>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

您的错误就在这一行:

for(var i=0;i&lt;rsp.photos.photo.length;i++){

&lt;是一个字符串字符,当您希望它是小于号<时。所以,改为:

for(var i=0;i<rsp.photos.photo.length;i++){