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>
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4676 | PHP | 8년 전 | 1663 | ||
| 4675 | PHP | 8년 전 | 2081 | ||
| 4674 | PHP | 8년 전 | 1928 | ||
| 4673 | PHP | 8년 전 | 2618 | ||
| 4672 | PHP | 8년 전 | 2086 | ||
| 4671 | PHP | 8년 전 | 2640 | ||
| 4670 | PHP | 8년 전 | 1930 | ||
| 4669 | PHP | 8년 전 | 1775 | ||
| 4668 | PHP | 8년 전 | 2332 | ||
| 4667 | PHP | 8년 전 | 1949 | ||
| 4666 | PHP | 8년 전 | 2112 | ||
| 4665 | PHP | 8년 전 | 2045 | ||
| 4664 | PHP | 8년 전 | 2014 | ||
| 4663 | PHP | 8년 전 | 2113 | ||
| 4662 | PHP | 8년 전 | 2083 | ||
| 4661 | JavaScript | 8년 전 | 2951 | ||
| 4660 | PHP | 8년 전 | 1978 | ||
| 4659 | PHP | 8년 전 | 2186 | ||
| 4658 | PHP | 8년 전 | 2017 | ||
| 4657 | 웹서버 | 8년 전 | 3697 | ||
| 4656 | JavaScript | 8년 전 | 4035 | ||
| 4655 | MySQL | 8년 전 | 2590 | ||
| 4654 | MySQL | 8년 전 | 5021 | ||
| 4653 | JavaScript | 8년 전 | 3137 | ||
| 4652 | PHP |
ycolor
|
8년 전 | 1949 | |
| 4651 | MySQL | 8년 전 | 5004 | ||
| 4650 | PHP | 8년 전 | 2038 | ||
| 4649 | PHP | 8년 전 | 2244 | ||
| 4648 | PHP | 8년 전 | 2320 | ||
| 4647 | MySQL | 8년 전 | 2278 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기