2013-05-31 5 views
0

내가 내 스프링 MVC 응용 프로그램을 만든 다음 아약스 전화를 ..을아약스 호출에 응답이 상태는

 alert("ready"); 
     $.ajax({ 
      type: "GET", 
      url: document.location.toString()+ "/dashboard", 
      success: function(response) { 
       alert(response); 
       alert(response.status);            
       $("#frameBody").contents().find("html").html(response); 
       // we have the response 
       if(response.status == "SUCCESS") { 

        alert(response); 
        // do nothing.. 
        // check for no content... if there is content... replace iframe 
        // $("#frameBody").attr('src', jsonObj.url); 
        // $(""#frameBody").contents().find("html").html(response); 
       } 
       else { 
        // do nothing yet 
       } 
      }, 
      error: function(e){ 
       $("#errors").attr("style", "display:inline") 
       $('#errors').html(e.responseText); 
       window.setTimeout("fadeErrorsDiv();", 5000); 
      } 
     }); 

내 MVC 컨트롤러는 확실하지 않은 이유 :

@RequestMapping(value = "/dashboard", method = RequestMethod.GET) 
@ResponseStatus(value=HttpStatus.OK) 
public String dashboard(Model model, HttpServletRequest req) { 

    int i = 0; 

    return "login"; 
} 

내 질문은 없다는 것이다 왜 내가 응답 상태를 생산하지 않는지 알 수 있습니까? ... 자바 스크립트에서 response.status를 확인할 때 정의되지 않은 이유가 무엇입니까? 어떤 아이디어 이건

답변

0

JQuery .get docs을 참조하십시오. 성공 콜백 내의 "응답"객체는 실제로 "로그인"으로 보일 것입니다. 그러므로 당신은 "login".status를 실제로 시도하고 있습니다.

관련 문제