1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Javascript isnt working

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Dec 14, 2013.

  1. Matthew Hawley

    Matthew Hawley Well-Known Member

    Can anyone tell me why this javascript isn't working?

    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: Dec 14, 2013

Share This Page