rpanchev9708

Problem 02

Nov 17th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Load Repos</title>
  6. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  7. </head>
  8. <body>
  9. <div id="text">
  10. GitHub username:
  11. <input type="text" id="username"/>
  12. <button onclick="loadRepos">Load Repos</button>
  13. </div>
  14. <ul id="results"></ul>
  15. <script>
  16. function loadRepos() {
  17. let username = $('#username').val();
  18. $.get("https://api.github.com/users/" + username + "/repos")
  19. .then(function (data) {
  20. $("#results").append($("<li>").text(data));
  21. })
  22. .catch(function () {
  23. $("#results").append($("<li>Error</li>"));
  24. });
  25. }
  26. </script>
  27. </body>
  28. </html>
Add Comment
Please, Sign In to add comment