• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>jQuery Ajax Method</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
                $.ajax("/examples/media/request_ajax.php")
12
                .done(function() {
13
                    alert("요청 성공");
14
                })
15
                .fail(function() {
16
                    alert("요청 실패");
17
                })
18
                .always(function() {
19
                    alert("요청 완료");
20
                });
21
            });
22
        });
23
    </script>
24
</head>
25
​
26
<body>
27
​
28
    <h1>$.ajax() 메소드</h1>
29
    <button id="requestBtn">$.ajax() 메소드 실행</button>
30
    <p id="text"></p>
31
    
32
</body>
33
​
34
</html>