Reputation: 1709
i have deployed a REST web service and the service return String as a response. When i send cross domain jQuery ajax request i get 'parsererror'.
Below is Spring Controller:
@RequestMapping(value="/TestService",method=RequestMethod.GET)
@ResponseBody
public String testServiceGet()
{
return "This is GET";
}
Below is jQuery ajax() method:
$.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);
}
});
The error which we received in FF browser error console is as below:
SyntexError: missing ; before statement
This is GET
-----^
Please help as soon as possible.
Upvotes: 2
Views: 1632
Reputation: 1709
Finally it solved.
I remove the contentType: 'text/plain'
, from the ajax method and it's working fine.
Upvotes: 3