【发布时间】:2012-08-14 06:28:11
【问题描述】:
我已经部署了一个 REST Web 服务,该服务返回字符串作为响应。 当我发送跨域 jQuery ajax 请求时,我得到'parsererror'。
下面是 Spring 控制器:
@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
-----^
请尽快提供帮助。
【问题讨论】:
标签: jquery spring-mvc cross-domain restful-url