I am sending the following AJAX request :
$.ajax({ type: 'POST',
data: $(this).parents('form:first').serialize(), url:'/myapp/comment/saveOrUpdate',
success: function(data,textStatus) {insertNewComment(data)},
error: function(xhr, textStatus, errorThrown) {alert(xhr.responseText);}
})
...and my controller action looks like this :
class CommentController {
...
def saveOrUpdate = {
...
if (error) {
response.sendError 419, 'You must wait at least 5 minutes before posting a new comment'
}
}}
Unfortunately, I never see the message I send in the HTTP response. Instead, I got an error HTML page generated from Tomcat/Apache (or Grails?) that looks like :
<html><head><title>Apache Tomcat/6.0-snapshot - Error report</title>
</head><body><h1>HTTP Status 419 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Cannot find message associated with key http.419</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0-snapshot</h3></body></html>
How can I bypass the generated error HTML page in order to retrieve from the JavaScript code the message 'You must wait...' ?
Thank you for your help.