【问题标题】:Parsererror for jQuery corss domain ajax request to Spring Rest web service对 Spring Rest Web 服务的 jQuery corss 域 ajax 请求的 Parsererror
【发布时间】: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


    【解决方案1】:

    终于解决了。

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

    【讨论】:

      猜你喜欢
      • 2015-06-05
      • 2012-04-23
      • 2014-12-14
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-29
      相关资源
      最近更新 更多