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
나는 언제나 활짝 핀 꽃보다는 약속에 찬 봉오리를, 소유하는 것보다는 욕망을, 완성보다는 진보를, 분별 있는 연령보다는 청소년 시절을 사랑한다. (앙드레 지드)