grailsg:remoteLink响应
如何使用jquery从使用g:remoteLink进行的ajax调用中获得响应grailsg:remoteLink响应,grails,Grails,如何使用jquery从使用g:remoteLink进行的ajax调用中获得响应 我尝试过使用nsaccess=“removeTask(e)”并使用e.responseText或e.response获取响应,但没有任何效果。在JQuery插件中使用Grails并使用remoteLink等远程函数时,为远程函数生成的代码如下所示: success: function(data, textStatus){ jQuery('#results').html(data); } <g:remoteLi
我尝试过使用
nsaccess=“removeTask(e)”
并使用e.responseText或e.response获取响应,但没有任何效果。在JQuery插件中使用Grails并使用remoteLink等远程函数时,为远程函数生成的代码如下所示:
success: function(data, textStatus){ jQuery('#results').html(data); }
<g:remoteLink controller="yourcontroller" action="youraction" update="[success: 'results']" onSuccess="yourFunction(data) ">Your link</g:remoteLink>
success:function(data,textStatus){ jQuery('#results').html(data); yourFunction(data); }
例如,如果将更新参数设置为“[success:'results']”,则会出现这种情况。正如您所看到的,main函数接收一个数据参数,我认为这是您要查找的,因此,如果您需要调用另一个使用该值的函数,您可以执行以下操作:
success: function(data, textStatus){ jQuery('#results').html(data); }
<g:remoteLink controller="yourcontroller" action="youraction" update="[success: 'results']" onSuccess="yourFunction(data) ">Your link</g:remoteLink>
success:function(data,textStatus){ jQuery('#results').html(data); yourFunction(data); }
希望这有帮助