2019.10.01

 

확인 버튼 클릭시 ajax 호출

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$(function() {
    $('#adminCheck').click(function() {
            
        var shopCode = $('#shopCode').val();
        var adminPw = $('#adminPw').val();
        var memberBirth = $('#memberBirth').val();         
            
        // ajax 호출을 위한 정보 기입
        var request = $.ajax({
            url: "/spendAdminCheck"// 호출 url
            method: "POST"// 전송방식
           data: {shopCode, adminPw, memberBirth}, // 파라미터
            dataType: "text" // 전송 받을 타입 ex) xml, html, text, json
        });
             
        // 호출 정상일 시 실행되는 메서드
        request.done(function( data ) {
            console.log(data);
        });
 
        // 호출 에러일 시 실행되는 메서드
        request.fail(function( jqXHR, textStatus ) {
            alert"Request failed: " + textStatus );
        });
 
        // 호출 정상 또는 에러 상관없이 실행
        request.always(function() {
            console.log('완료');
        });
    });
});
 

 

 

 controller

1
2
3
4
5
6
7
8
@RequestMapping(value = "/spendAdminCheck"// 응답 url
public @ResponseBody int adminCheck(String shopCode, String memberBirth, String adminPw) {
        
    int result = spendService.spendAdminCheck(shopCode, memberBirth, adminPw); // DB 조회
    System.out.println(result + " <-- result adminCheck() SpendController.java"); // 결과 2
        
    return result;
}
 

 

 DB 조회 결과

 

결과 화면

 콘솔창에 결과값이 잘 찍힘

+ Recent posts