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
자식에게 미움을 받은 적이 없다면 당신은 진정한 부모가 되어 본 적이 없는 것이다.