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
우리가 행복한지의 여부는 우리들 각자가 진짜로 원하는 삶을 향해서 얼마나 당당하게 다가가고 있느냐에 달렸다. 그 채점 또한 저마다의 몫이다. (김한길)