ajax 를 이용한 비동기식 삭제 데이터 처리. > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

ajax 를 이용한 비동기식 삭제 데이터 처리. 정보

jQuery ajax 를 이용한 비동기식 삭제 데이터 처리.

본문

javascript

 

function confirm_action(action, msg) {

if (confirm(msg)) {

return $.ajax({

type : 'post',

async : false,

url : action,

dataType : 'json', 

timeout : 30000,

cache : false ,

success : function(response, status, request) {

return response;

}

});

 

}

}

 

$(document).ready(function() {

 

    $(document).on('click', '.delete', function (e) {

 

        e.preventDefault();

        var action = $(this).attr('href');

 

        var req = confirm_action(action, "선택하신 정보를 삭제하시겠습니까?");

        req.success(function(data) {

            if (data.rescd == '00') {

                alert(data.restx);

                location.reload();

            }

            else {

                alert(data.restx);

            }

        });

 

    });

});

 

 

 

 

html

<a href="./delete.php" class="ws-delete">삭제</a> 

추천
1
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로