I am trying to list my github repos through their api but its not showing up on my page but by using the exact same code its working here on JSFiddle
我试图通过他们的api列出我的github repos,但它没有显示在我的页面上但是使用完全相同的代码在JSFiddle上工作
Debugging shows that the script is being called but its just not loading in its <div>
:
调试显示正在调用脚本,但它只是不在其
<div id="repos">
<ul id="repo_list">
</ul>
</div>`
Here is the markup in my source code:
这是我的源代码中的标记:
<section id="git-hub">
<div class="container">
<div class="box">
<div class="center">
<h2>GitHub</h2>
<p class="lead">Go on! Take a look through my repos!</p>
<div id="repos">
<ul id="repo_list">
</ul>
</div>
<div id="repo_content"></div>
<script>
$.ajax({
type: "GET",
url: "https://api.github.com/users/google/repos",
dataType: "json",
success: function(result) {
for( i in result ) {
$("#repo_list").append(
"<li><a href='" + result[i].html_url + "' target='_blank'>" +
result[i].name + "</a></li>"
);
console.log("i: " + i);
}
console.log(result);
$("#repo_count").append("Total Repos: " + result.length);
}
});
</script>
</div><!--/.center-->
</div>
</div>
</section><!--/#pricing-->
Does anybody know what could be the reason?
有谁知道可能是什么原因?
1 个解决方案
#1
1
You're putting this script
tag above where you're loading your jQuery. Place this script
tag below where you're loading your jQuery.
您将此脚本标记放在您加载jQuery的位置。将此脚本标记放在您加载jQuery的位置下方。
#1
1
You're putting this script
tag above where you're loading your jQuery. Place this script
tag below where you're loading your jQuery.
您将此脚本标记放在您加载jQuery的位置。将此脚本标记放在您加载jQuery的位置下方。