Matthew Hawley
Well-known member
Can anyone tell me why this javascript isn't working?
Nvm I didnt wrap it in $(function() { });
Nvm I didnt wrap it in $(function() { });
Code:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$("#btn_get_repos").click(function() {
$.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>
<li id="ourTab" class="profileContent">
<div id="repos">
<ul id="repo_list"></ul>
</div>
<div id="repo_content"></div>
<button id="btn_get_repos">Get Repos</button><span id="repo_count"></span>
</li>
Last edited: