Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $( document ).ready(function() {
- $( "#showButton" ).on("click", listUsers );
- $( "#showAge" ).on("click", listAge );
- $( "#showGender" ).on("click", listGender );
- $( "#showCourse" ).on("click", listCourse );
- $( "#showSanjaya" ).on("click", listSanjaya );
- $( "#showSanjayaSeite" ).on("click", Sanjaya.html );
- });
- function listUsers() {
- console.log("fetching users.");
- var pathname = window.location.pathname;
- //console.log("http://localhost:8080"+pathname+"api/user");
- $.getJSON("http://localhost:8080"+pathname+"api/user", null, onUserResult);
- }
- function listSanjaya() {
- console.log("fetching users.");
- var pathname = window.location.pathname;
- //console.log("http://localhost:8080"+pathname+"api/user");
- $.getJSON("http://localhost:8080"+pathname+"api/user/Sanjaya", null, onSanjayaResult);
- }
- function listAge() {
- console.log("fetching Age.");
- var pathname = window.location.pathname;
- // console.log("http://localhost:8080"+pathname+"api/user");
- $.getJSON("http://localhost:8080"+pathname+"api/user/age", null, onAgeResult);
- }
- function listGender() {
- console.log("fetching Gender.");
- var pathname = window.location.pathname;
- //console.log("http://localhost:8080"+pathname+"api/user");
- $.getJSON("http://localhost:8080"+pathname+"api/user/gender", null, onGenderResult);
- }
- function listCourse() {
- console.log("fetching Course.");
- var pathname = window.location.pathname;
- //console.log("http://localhost:8080"+pathname+"api/user");
- $.getJSON("http://localhost:8080"+pathname+"api/user/course", null, onCourseResult);
- }
- function onUserResult(userData) {
- $.each(userData, function (i, item) {
- $("#content").append("<p>Admin: "+item.name+"</p>");
- });
- }
- function onSanjayaResult(userData) {
- // $.each(userData, function (i, item) {
- $("#content").append("<p>Name: "+userData.name+"</p>");
- $("#content").append("<p>I.D.: "+userData.id+"</p>");
- $("#content").append("<p>Age: "+userData.age+"</p>");
- $("#content").append("<p>Gender: "+userData.gender+"</p>");
- $("#content").append("<p>Course: "+userData.course+"</p>");
- // });
- }
- function onAgeResult(strings) {
- console.log(strings);
- $.each(strings, function (i, age) {
- $("#content").append("<p>Age: "+age+"</p>");
- });
- }
- function onGenderResult(strings) {
- console.log(strings);
- $.each(strings, function (i, gender) {
- $("#content").append("<p>Gender: "+gender+"</p>");
- });
- }
- function onCourseResult(strings) {
- console.log(strings);
- $.each(strings, function (i, course) {
- $("#content").append("<p>Course: "+course+"</p>");
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement