【发布时间】:2013-01-16 23:43:40
【问题描述】:
我正在尝试使以下代码正常工作,以便在选择图像时将项目内容加载到页面中。 I have the images loading from the behance api, but I am struggling with the second bit when the a is selected it should take the url from the page and add it to the JSON to load each project content into the page.谁能看到我的起点
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var jqxhr;
jqxhr = $.getJSON("http://www.behance.net/v2/users/USER/projects?api_key=KEY&callback=?", function(data) {
var project_str = "";
for(var i=0; i< data.projects.length; i++){
obj = {};
obj = data.projects[i];
project_str += '<a class="link" href="#' + obj.id + '"><img src="' + obj.covers['404'] + '" /></a>'; }
$('#behance_container div').append(project_str);
});
});
$('a.link').click(function(){
var hash = location.hash.replace("#","");
var jqxhri;
jqxhri = $.getJSON("http://www.behance.net/v2/projects/' + hash + '?api_key=KEY&callback=?", function(data) {
$('#behance_header h3').html(data.project.name);
var project_data = '<p>' + data.project.description + '</p>';
$('#behance_project').html(project_data); });
});
</script>
</head>
<body>
<div id='behance_container'>
<div></div>
</div>
<div id='behance_header'><h3></h3><p></p></div> <div id='behance_project'></div>
</body>
</html>
【问题讨论】:
-
谁能看到我做错了什么,为什么它没有在选择时加载内容,我真的可以帮忙
-
在不知道自己想要做什么的情况下无法提供帮助。你已经发布了一大堆代码。目的是什么?究竟是什么不工作?
-
缩进混乱是不可能阅读代码的。请正确格式化您的代码。
-
我已更新代码以显示我试图显示第一部分加载包含在 URL 中的图像,第二部分单击时我想获取该 URL 并将其插入JSON。任何人都可以帮助在哈希后插入选定的页面 URL 吗?