Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 使用g:formRemote和Grails获取responseText_Ajax_Grails - Fatal编程技术网

Ajax 使用g:formRemote和Grails获取responseText

Ajax 使用g:formRemote和Grails获取responseText,ajax,grails,Ajax,Grails,我正在尝试使用formRemote访问ajax调用失败时的responseText <g:remoteLink controller="answer" action="delete" id="${answer.id}" update="questions" onFailure="handleError(response)" onComplete="assingActionTestElems()"></g:remoteLink> 这是我在控制器中的多个ajax处理错误之

我正在尝试使用formRemote访问ajax调用失败时的responseText

<g:remoteLink controller="answer" action="delete" id="${answer.id}"  update="questions" onFailure="handleError(response)" onComplete="assingActionTestElems()"></g:remoteLink>
这是我在控制器中的多个ajax处理错误之一

 render(status: 500, text: message(code: 'edition.answer.delete.pending'))

?我如何访问短信?

我找到了解决方案。这很简单,但没有文档记录。抛出错误时会隐式显示3个字段,这是访问这些字段的方法:

onFailure="handleError(XMLHttpRequest,textStatus,errorThrown)"

   var handleError = function(XMLHttpRequest,textStatus,errorThrown){
       alert(XMLHttpRequest.responseText);
   }

您可以根据需要使用一个或全部

在你的IDE上,你没有收到任何错误吗?在IDE上?我抛出了一个500 http错误,没有发生其他错误。只在firebug中使用。试试json怎么样
onFailure="handleError(XMLHttpRequest,textStatus,errorThrown)"

   var handleError = function(XMLHttpRequest,textStatus,errorThrown){
       alert(XMLHttpRequest.responseText);
   }