Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Tags more
Archives
Today
Total
관리 메뉴

jeongwon

[Error] Ajax 를 이용한 이미지 파일 삭제 시 오류 본문

Error log

[Error] Ajax 를 이용한 이미지 파일 삭제 시 오류

jeongwon_ 2022. 11. 11. 02:52

상황:

Ajax 를 이용하여 미리보기 출력한 이미지 원본을 삭제하고, 미리보기 화면을 hide() 또 는 remove() 를 이용해 보이지 않게 하려고 했으나,

기존 img src="" 주소를 먼저 읽어들임으로써 success 이하의 코드가 실행되지 않는 상황.

 

해결: 

비동기식 => 동기식 설정

 

$("#fileDel").click(function(){
if(confirm('삭제하시겠습니까?')){
$.ajax({
type:"post",
url:"${path}/admin/popup_file_delete.do",
async: false,
data: {"no":"${dto.no}"},
success: function(result){
if(result=='deleted'){
$("#fileImage").remove();
alert('삭제되었습니다.');
}
}
})
}
});