• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>Ajax jQuery</title>
7
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
8
    <script>
9
        $(function() {
10
            $("#requestBtn").on("click", function() {
11
                // GET 방식으로 서버에 HTTP 요청을 보냄.
12
                $.get("/examples/media/jquery_ajax_data.txt", function(data, status) {
13
                    $("#text").html(data + status); // 전송받은 데이터와 전송 성공 여부를 보여줌.
14
                });
15
            });
16
        });
17
    </script>
18
</head>
19
​
20
<body>
21
​
22
    <h1>$.get() 메소드</h1>
23
    <button id="requestBtn">GET 방식으로 데이터 불러오기!</button>
24
    <p id="text"></p>
25
    
26
</body>
27
​
28
</html>