Jquery/Javascript Flickr Gallery.. 非常需要帮助
因此,我正在开发一个项目,该项目基本上将用户的输入作为闪烁的“标签”并存储它,然后重用它来制作从标签中提取的闪烁图像的图库。现在我想我已经得到了我想要做的大部分内容...但它只是没有 100% 工作...或者根本没有工作,因为没有任何图像再出现,但这是我的代码,
<head>
<meta charset="utf-8" />
<title>Image Gallery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="js/index.js"></script>
<script>
$(function() {
$("#test").keyup(function(){
var value = $(this).val()
$.getJSON(
"http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
{
tags: "value",
tagmode: "any",
format: "json"
},
function(data) {
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
if ( i == 20 ) return false;
});
}
);
};
});
</script>
</head>
<body>
<form>
Input a Tag for Flicker Images: <input id="test" type="text" />
</form>
<div id="images"></div>
</body>
看起来好像是这样很简单,但我就是不知道我做错了什么。
So i'm working on a project that basically takes the user's input as a "tag" of sorts for flicker and stores it, to then reuse it to make a gallery of the flicker images it pulls up from the tag. Now I think i've got mostly what i'm trying to do... but It's just not working 100%... or really at all because none of the images show up anymore, but here's my code
<head>
<meta charset="utf-8" />
<title>Image Gallery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="js/index.js"></script>
<script>
$(function() {
$("#test").keyup(function(){
var value = $(this).val()
$.getJSON(
"http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
{
tags: "value",
tagmode: "any",
format: "json"
},
function(data) {
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
if ( i == 20 ) return false;
});
}
);
};
});
</script>
</head>
<body>
<form>
Input a Tag for Flicker Images: <input id="test" type="text" />
</form>
<div id="images"></div>
</body>
It seems like it's something very simple but I JUST cannot figure out what i'm doing wrong..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你缺少一个分号:
应该是:
我还会在你的
标签上放置一个
type="text/javascript"
属性,另一件事是结束标签(最后两个)是:
应该是
});
这里只是返工:
这里是一个工作示例:http://jsfiddle.net/MarkSchultheiss/NFRsX/
you are missing a semi colon:
should be:
I would also put a
type="text/javascript"
attribute on your<script>
tagsone other thing, the closing tags (last two) are:
should be
});
ONLYhere is the rework:
HERE is a working example: http://jsfiddle.net/MarkSchultheiss/NFRsX/
删除值周围的双引号;
使
标签:“值”为标签:值
还要检查括号错误。您的代码将运行得很好..我让它工作了..
Remove the double quotes around value;
make
tags:"value" as tags:value
Also check for parenthesis errors.and your code will run just fine..i made it to work..
我整理了一些您的代码,并且可以使以下内容正常工作:
我将 $.getJson 作为回调传递给 setTimeout,因此您不会在每次击键时都点击 flickr。
I tidied up a little your code and can get the following to work:
I passed $.getJson as a callback to setTimeout, so you're not hitting flickr on every keystroke.
在客户端使用 flickr api 需要 jsonp。请查看问题https://stackoverflow.com/a/5945676/24047
Using the flickr api on client side requires jsonp. please have a look at question https://stackoverflow.com/a/5945676/24047