2012-08-14 3 views
2

나는 REST 웹 서비스를 전개했으며 서비스는 String을 응답으로 리턴한다. 크로스 도메인 jQuery 아약스 요청을 보낼 때 'parsererror'가 표시됩니다.Spring Rest 웹 서비스에 대한 jQuery 도메인 용 Ajax 요청에 대한 파서 오류

$.ajax({ 
    url: 'http://localhost:8080/Example_REST_WS_Deploy/service/TestService', 
    dataType: 'jsonp', 
    crossDomain: true, 
    contentType: 'text/plain', 
    success : function(data, textStatus, xhr) { 
     alert(data); 
    }, 
    error : function(xhr, textStatus, errorThrown) { 
     alert("Error ->" + textStatus); 
    } 
}); 
우리가 FF 브라우저 오류 콘솔에서받은 오류가 다음과 같습니다

:

SyntexError: missing ; before statement 
This is GET 
-----^ 
다음
@RequestMapping(value="/TestService",method=RequestMethod.GET) 
@ResponseBody 
public String testServiceGet() 
{ 
    return "This is GET"; 
} 

jQuery를 아약스() 방법 : 아래

봄 컨트롤러입니다

가능한 빨리 도움을 받으십시오.

답변

3

마지막으로 해결되었습니다.

나는 ajax 메서드에서 contentType: 'text/plain'을 제거하고 잘 동작한다.

관련 문제