2011-04-22 2 views
1

json은 클라이언트와 서버 간의 통신에 독점적으로 사용하기 때문에 일반적인 mootools 요청을 request.JSON으로 전환하려고합니다. I는 JSON 요청으로 정의 :mootools 요청에서 응답 상태 코드가 http 200 일 때 onFailure가 호출됩니다 .JSON

var jsonRequest = new Request.JSON({ 

     url: '/ServletContext/servlet', 
     onRequest: function(){ 
      // Just a class to make the cursor change to progress 
      container.addClass('request-waiting'); 
     }, 
     // validationMessages should be a json object containing 
     // messages on problems validating user input from server 
     onSuccess: function(validationMessages){ 
      container.removeClass('request-waiting'); 
     }, 
     onFailure: function(requestObj){ 
      container.removeClass('request-waiting'); 
     } 
    }).post({'context': context,'title': title}); 

나는 현재 크롬이 테스트를하고있어, 그리고 요청이 미세 게시하고, 내가 기대하고있어 내용으로는 HTTP (200)를 반환; 하지만 onFailure 콜백은 계속 호출됩니다. onSuccess 메서드가 호출되지 않는 이유가 궁금합니다.

나는 응답 (의도적으로) 다시 전송하고있어 JSON 문자열 : 내가 Mootools의 1.3, 톰캣 7

편집을 사용하고

"{titleErrors: [], contextErrors: ['Context must be more than 40 characters']}" 

: 스택 Mootools의를 진행 한 후 조금, json.decode에 대한 호출을 찾았지만 실패했습니다. 내 json 문자열이 잘못 되었기 때문에 그럴 것 같아요. 나는 오랫동안 json을 사용하지 않았기 때문에 놀라지 않을 것이지만 이것이 효과가있을 것이라고 생각했을 것이다. 나는이 문제를 조사하고있다. 그러나 만약 당신이 내 아들을 눈으로 봤고 그 문제를 볼 수 있다면 그것은 인정 될 것이다.

답변

3

json의 형식이 잘못되었습니다. (변수 이름 주위에 참고 인용)

{titleErrors: [], contextErrors: ["Context must be more than 40 characters"]} 

과이 있었어야 :

{"titleErrors": [], "contextErrors": ["Context must be more than 40 characters"]} 
을 나는이 있었다
관련 문제