Advertisement
FranciG

Script.js

Jun 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. $( document ).ready(function() {
  2. $( "#showButton" ).on("click", listUsers );
  3. $( "#showAge" ).on("click", listAge );
  4. $( "#showGender" ).on("click", listGender );
  5. $( "#showCourse" ).on("click", listCourse );
  6. $( "#showSanjaya" ).on("click", listSanjaya );
  7. $( "#showSanjayaSeite" ).on("click", Sanjaya.html );
  8.  
  9. });
  10.  
  11. function listUsers() {
  12. console.log("fetching users.");
  13. var pathname = window.location.pathname;
  14. //console.log("http://localhost:8080"+pathname+"api/user");
  15. $.getJSON("http://localhost:8080"+pathname+"api/user", null, onUserResult);
  16.  
  17. }
  18.  
  19. function listSanjaya() {
  20. console.log("fetching users.");
  21. var pathname = window.location.pathname;
  22. //console.log("http://localhost:8080"+pathname+"api/user");
  23. $.getJSON("http://localhost:8080"+pathname+"api/user/Sanjaya", null, onSanjayaResult);
  24.  
  25. }
  26. function listAge() {
  27. console.log("fetching Age.");
  28. var pathname = window.location.pathname;
  29. // console.log("http://localhost:8080"+pathname+"api/user");
  30. $.getJSON("http://localhost:8080"+pathname+"api/user/age", null, onAgeResult);
  31. }
  32. function listGender() {
  33. console.log("fetching Gender.");
  34. var pathname = window.location.pathname;
  35. //console.log("http://localhost:8080"+pathname+"api/user");
  36. $.getJSON("http://localhost:8080"+pathname+"api/user/gender", null, onGenderResult);
  37. }
  38. function listCourse() {
  39. console.log("fetching Course.");
  40. var pathname = window.location.pathname;
  41. //console.log("http://localhost:8080"+pathname+"api/user");
  42. $.getJSON("http://localhost:8080"+pathname+"api/user/course", null, onCourseResult);
  43. }
  44.  
  45.  
  46.  
  47.  
  48. function onUserResult(userData) {
  49. $.each(userData, function (i, item) {
  50. $("#content").append("<p>Admin: "+item.name+"</p>");
  51. });
  52. }
  53. function onSanjayaResult(userData) {
  54. // $.each(userData, function (i, item) {
  55. $("#content").append("<p>Name: "+userData.name+"</p>");
  56. $("#content").append("<p>I.D.: "+userData.id+"</p>");
  57. $("#content").append("<p>Age: "+userData.age+"</p>");
  58. $("#content").append("<p>Gender: "+userData.gender+"</p>");
  59. $("#content").append("<p>Course: "+userData.course+"</p>");
  60. // });
  61. }
  62. function onAgeResult(strings) {
  63. console.log(strings);
  64. $.each(strings, function (i, age) {
  65. $("#content").append("<p>Age: "+age+"</p>");
  66. });
  67. }
  68. function onGenderResult(strings) {
  69. console.log(strings);
  70. $.each(strings, function (i, gender) {
  71. $("#content").append("<p>Gender: "+gender+"</p>");
  72. });
  73. }
  74. function onCourseResult(strings) {
  75. console.log(strings);
  76. $.each(strings, function (i, course) {
  77. $("#content").append("<p>Course: "+course+"</p>");
  78. });
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement