Angular cannot parse Spring answer

I'm having some problems trying to get a response from the Spring RESTful web service to an AngularJS client.

I use ResponseEntity<String>to return the response to the client. This only works when the status code is returned, but using the "Angular error" parameter, Unexpected token Ran error occurs when sending a response message in the body.

What am I doing wrong?

return new ResponseEntity<String>(HttpStatus.OK);

But this does not work:

return new ResponseEntity<String>("Report was updated successfully", HttpStatus.OK);

AngularJs Code:

$http.get(url, header)
    .success(function(data, status, headers, config) {
        // some logic
    }).error(function(resp, status) {
        // some logic
    });

Answer:

Screen capture

+4
source share
1 answer

Is Angular expecting JSON or HTML / text?

/javascript /json text/html. , Angular JSON JSONP , , R ( ).

, , JSONP JSON ..

+1

All Articles