Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Title of the document</title>
  5.     <meta charset="UTF-8">
  6. </head>
  7. <body>
  8. <script src="http://code.jquery.com/jquery-1.11.2.min.js">
  9. </script>
  10.  
  11.  
  12. <script>
  13.     function refresh() {
  14.         $.get( "http://localhost:9090/test-mvn-app/users",
  15.                 function(data) {
  16.                     var html = "";
  17.  
  18.                     for (var i = 0; i < data.length; i++) {
  19.                         html += "<span>";
  20.                         html += data[i].name;
  21.                         html += "</span>";
  22.                         html += "<br>";
  23.                     }
  24.  
  25.                     $("#users").html(html);
  26.                 }
  27.         );
  28.     }
  29.  
  30.     function clearDiv() {
  31.         $("#users").html("");
  32.     }
  33.  
  34.     function addUser() {
  35.         var userName = $("#userName").val();
  36.         $.post("http://localhost:9090/test-mvn-app/addUser",
  37.                 {name : userName},
  38.                 function (data) {
  39.                 });
  40.     }
  41.  
  42.     function refreshPosts() {
  43.         $.get( "http://localhost:9090/test-mvn-app/posts",
  44.                 function(data) {
  45.                     var html = "";
  46.  
  47.                     for (var i = 0; i < data.length; i++) {
  48.                         html += "<span>";
  49.                         html += data[i].text;
  50.                         html += "</span>";
  51.                         html += "<br>";
  52.                     }
  53.  
  54.                     $("#users").html(html);
  55.                 }
  56.         );
  57.     }
  58. </script>
  59.  
  60. <div id="users">
  61.  
  62. </div>
  63.  
  64.  
  65. <div id="calculator">
  66.     <div class="keys">
  67.         <input type="button" onclick="refresh();" value="refresh"/>
  68.         <input type="button" onclick="refreshPosts();" value="refreshPosts"/>
  69.         <input type="button" onclick="clearDiv();" value="clear"/>
  70.         <p><input id="calc_value" type="text" value=""></p>
  71.     </div>
  72. </div>
  73.  
  74. <hr>
  75. <hr>
  76. <hr>
  77. <div>
  78.     <p><input id="userName" type="text" value=""></p>
  79.     <input type="button" onclick="addUser();" value="addUser"/>
  80. </div>
  81.  
  82. </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement