我试图让以下代码工作,以便在选择图像时将项目内容加载到页面中。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>