2

私はRESTWebサービスをデプロイし、サービスは応答として文字列を返します。クロスドメインjQueryajaxリクエストを送信すると、「parsererror」が表示されます。

以下はSpringControllerです。

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

以下はjQueryajax()メソッドです。

$.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
-----^

できるだけ早く助けてください。

4

1 に答える 1

3

ついに解決しました。

contentType: 'text/plain'、をajaxメソッドから削除すると、正常に機能しています。

于 2012-08-14T07:25:24.750 に答える