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

· 8년 전 · 2815

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,290
PHP 8년 전 조회 2,474
PHP 8년 전 조회 2,371
PHP 8년 전 조회 2,037
PHP 8년 전 조회 2,438
PHP 8년 전 조회 2,144
PHP 8년 전 조회 2,253
기타 8년 전 조회 4,065
PHP 8년 전 조회 2,848
PHP 8년 전 조회 2,036
PHP 8년 전 조회 2,680
PHP 8년 전 조회 1,871
jQuery 8년 전 조회 2,926
MySQL 8년 전 조회 3,832
jQuery 8년 전 조회 2,816
JavaScript 8년 전 조회 2,498
PHP 8년 전 조회 2,145
PHP 8년 전 조회 1,888
PHP 8년 전 조회 2,412
PHP 8년 전 조회 3,013
PHP 8년 전 조회 2,370
PHP 8년 전 조회 2,289
node.js 8년 전 조회 1,844
node.js 8년 전 조회 2,285
node.js 8년 전 조회 2,008
PHP 8년 전 조회 2,493
PHP 8년 전 조회 2,643
PHP 8년 전 조회 2,492
PHP 8년 전 조회 2,516
PHP 8년 전 조회 2,680