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

· 8년 전 · 2723

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> 

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

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

+
분류 제목 글쓴이 날짜 조회
OS 8년 전 조회 3,197
PHP 8년 전 조회 2,368
PHP 8년 전 조회 2,266
PHP 8년 전 조회 1,933
PHP 8년 전 조회 2,337
PHP 8년 전 조회 2,060
PHP 8년 전 조회 2,152
기타 8년 전 조회 3,943
PHP 8년 전 조회 2,748
PHP 8년 전 조회 1,935
PHP 8년 전 조회 2,579
PHP 8년 전 조회 1,769
jQuery 8년 전 조회 2,818
MySQL 8년 전 조회 3,736
jQuery 8년 전 조회 2,724
JavaScript 8년 전 조회 2,393
PHP 8년 전 조회 2,062
PHP 8년 전 조회 1,786
PHP 8년 전 조회 2,305
PHP 8년 전 조회 2,917
PHP 8년 전 조회 2,269
PHP 8년 전 조회 2,175
node.js 8년 전 조회 1,754
node.js 8년 전 조회 2,199
node.js 8년 전 조회 1,913
PHP 8년 전 조회 2,399
PHP 8년 전 조회 2,536
PHP 8년 전 조회 2,388
PHP 8년 전 조회 2,422
PHP 8년 전 조회 2,590
🐛 버그신고