$.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);}
})
...和我控制器操作是这样的:
class CommentController {
...
def saveOrUpdate = {
...
if (error) {
response.sendError 419, 'You must wait at least 5 minutes before posting a new comment'
}
}}
不幸的是,我从来没有看到我在HTTP响应发送消息。相反,我从Tomcat /阿帕奇(或Grails的?)产生错误的HTML页面,看起来像:
Apache Tomcat/6.0-snapshot - Error reportHTTP Status 419 -
type Status report
message
description Cannot find message associated with key http.419
Apache Tomcat/6.0-snapshot
我怎样才能绕过产生的错误HTML页面,以便从JavaScript代码的消息“您检索必须等待......'?
谢谢你的帮助。