Html & Script

jquery $.ajax error 확인

컨텐츠 정보

본문

$.ajax({

    url: 'test.php', // PHP 파일 경로

    type: 'POST',

    data: { post_id: postId

    dataType: "json",

    success: function(result) {

        ....

    },

    error: function(jqXHR, textStatus, errorThrown) {

        console.log("요청 실패!");

        console.log("상태 코드:", jqXHR.status); // HTTP 상태 코드 (예: 404, 500)

        console.log("에러 메시지:", textStatus); // 에러 유형 (예: "timeout", "error", "abort", "parsererror")

        console.log("추가 정보:", errorThrown); // 서버에서 전달한 에러 메시지

        console.log("응답 본문:", jqXHR.responseText); // 서버에서 반환된 응답 (에러 상세 메시지)

    }

});

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
참된 행복은 눈에 보이지 않는다. 참된 행복은 작지만 자기 일에 만족하고 자기 안에서 그것을 찾는 사람에게만 보이도록 가만 가만히 찾아온다.