차근차근/JQuery Ajax Jstl

Ajax 오류 메시지

예쁜꽃이피었으면 2015. 1. 19. 14:44


검색어 : ajax status 500 error

밑에 나와있는대로 해봤지만.. 어떤 경우 전송 에러가 발생하는지 모르겠다.





http://jiniweb.tistory.com/7

if(xmlHttpReq.readyStatus == 4){

strResponse = xmlHttpTeq.responseText ;

switch(xmlHttpReq.status){

case 404 :

alert('Error:Not Found.The requested URL'+

strURL+'could not be found');

break;

case 500:

handleErrFullPage(strResponse);

break;

default:

if(strResponse.indexOf('Debug:')> -1){

alert(strResponse);

}

else{

eval(strResultFunc+'(strResponse);');

}

break;

}

}

function handleErrFullPage(strln){

var errorWin;

try{

errorWin=window.open('',errorWin);

errorWin.document.body.innerHTML = strln;

}

catch(e){

alert('An error occurred,but the error message cannot be'+

'displayed becouse of uourt browser \'s pop-up blocker\n'+

'Planse allow pop-ups from this Web sitr');

}

}

}





[ JQUERY ] ajax 사용 시 error 발생 확인

http://shonm.tistory.com/entry/JQUERY-ajax-%EC%82%AC%EC%9A%A9-%EC%8B%9C-error-%EB%B0%9C%EC%83%9D-%ED%99%95%EC%9D%B8


$.ajax({   
     type: "POST",  
     url: "/region/regionCityChange",   
     data: param,   //&a=xxx 식으로 뒤에 더 붙이면 됨
     dataType: "text",
     success: siguResult,
     error:function(request,status,error){
        alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
       }
     }
 );

 

와 같이 작성 하면 error 에서 에러가 왜 발생 했는지 알려 준다.

 

나 같은 경우 200 코드 (성공) 이 뜨는데 dataType 을 잘 못 받고 있어서

 

success 함수로 나오지 않는 것을 에러 수정 할 수 있었다.


반응형

'차근차근 > JQuery Ajax Jstl' 카테고리의 다른 글

[jQuery] jQuery API (6/7) - Ajax  (0) 2015.01.19
ajax form 정리  (0) 2015.01.19
jQuery Cycle Plugin - 이미지 슬라이드  (0) 2014.12.24
터치 이미지 슬라이드  (0) 2014.12.24
Jquery 로 tab(탭) 구현하기  (0) 2014.11.14