이재용

ajax 사용으로 속도 개선, 출력 형식 변경

...@@ -3,34 +3,54 @@ ...@@ -3,34 +3,54 @@
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <title><%= title %></title> 5 <title><%= title %></title>
6 - <link rel="icon" href = "FindMelogo.png"> 6 + <link rel="icon" href = "DUDUDUNGA.PNG">
7 <link rel="stylesheet" href="css/style.css"> 7 <link rel="stylesheet" href="css/style.css">
8 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> 8 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
9 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> 9 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
10 <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> 10 <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> 11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
12 <script> 12 <script>
13 - $(document).ready(function(){ 13 + function setEvent() {
14 - 14 + $("#searchButton").click(function(){
15 -
16 - $("button#searchButton").click(function(){
17 var name = $("input").val(); 15 var name = $("input").val();
18 - location.href = "http://localhost:3000/search/" + name; 16 + getUserInfo(name);
19 }) 17 })
18 + }
19 + function getUserInfo(name) {
20 + var _this = this;
21 + $.ajax({
22 + method : 'GET',
23 + async : false,
24 + url : '/api/search/'+name
25 + }).done(function(result){
26 + _this.renderData(result);
27 + });
28 + }
29 + function renderData(data) {
30 + console.log(data)
31 + $('#resultData').html('');
32 + $.each(data,function(){
33 + var liEl = "<li>" + this + "</li>";
34 + $("#resultData").append(liEl);
35 + });
36 + }
37 + $(document).ready(function(){
38 + setEvent();
20 }); 39 });
21 </script> 40 </script>
22 </head> 41 </head>
23 <body> 42 <body>
24 <div class="imgOpacity"> 43 <div class="imgOpacity">
25 <div class="center"> 44 <div class="center">
26 - <img src= "FindMelogo.png" width = 300, height = 300/> 45 + <img src= "DUDUDUNGA.PNG" width = 300, height = 300/>
27 </div> 46 </div>
28 <div class="center2"> 47 <div class="center2">
29 <input type="text" class="input_text" placeholder="소환사 이름"> 48 <input type="text" class="input_text" placeholder="소환사 이름">
30 <span class="input-group-btn"> 49 <span class="input-group-btn">
31 - <button id="searchButton" class="btn btn-primary" type="button" onclick="search(name)">click!</button> 50 + <button id="searchButton" class="btn btn-primary" type="button">click!</button>
32 </span> 51 </span>
33 </div> 52 </div>
53 + <ul id="resultData" style="margin-top:100px"></ul>
34 </div> 54 </div>
35 </body> 55 </body>
36 </html> 56 </html>
......