2012-08-14 91 views
2

我已经部署了一个REST Web服务和服务返回String作为响应。 当我发送跨域jQuery ajax请求我得到'parsererror'。parsererror jQuery corss域ajax请求到Spring Rest web服务

下面是弹簧控制器:

@RequestMapping(value="/TestService",method=RequestMethod.GET) 
@ResponseBody 
public String testServiceGet() 
{ 
    return "This is GET"; 
} 

下面是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 
-----^ 

请尽快帮忙。

回答

3

最后解决了。

我从ajax方法中删除了contentType: 'text/plain',它工作正常。