如何在 Grails 3.2.3 中使用 ajax
How to use ajax in Grails 3.2.3
我在 grails 2.4.7 工作。最近我转向了 grails 3.Previously 我使用 grails 自定义标签进行 ajax 调用,如 remoteFunction、formRemote。这些标签不适用于最近的 version.Can 谁能告诉我最新版本使用 ajax 的最佳方法。
是的,从 2 开始。4.x g:remoteFunction
已在 grails 中弃用。
看到这个。 http://docs.grails.org/2.4.1/ref/Tags/remoteFunction.html
不过,您始终可以使用下面的 javascript/jQuery ajax 函数,它的功能完全相同。
<g:javascript>
function callMyAjax(){
$.ajax({
url:'${g.createLink( controller:'yourcontroller', action:'youraction')}',
data:{
param1:param1,
param2:param2
}
});
}
</g:javascript>
<input type="button" onclick="callMyAjax()"/>
如我所见,ajax-tags
由于效率低下问题已被弃用。他们建议 使用 Ajax 或原生 javascript。
无论如何,如果您仍然需要它们,可以使用作为迁移库的 grails 3 插件,但您也可以使用它:
compile 'org.grails.plugins:ajax-tags:1.0.0.RC1'
我在 grails 2.4.7 工作。最近我转向了 grails 3.Previously 我使用 grails 自定义标签进行 ajax 调用,如 remoteFunction、formRemote。这些标签不适用于最近的 version.Can 谁能告诉我最新版本使用 ajax 的最佳方法。
是的,从 2 开始。4.x g:remoteFunction
已在 grails 中弃用。
看到这个。 http://docs.grails.org/2.4.1/ref/Tags/remoteFunction.html
不过,您始终可以使用下面的 javascript/jQuery ajax 函数,它的功能完全相同。
<g:javascript>
function callMyAjax(){
$.ajax({
url:'${g.createLink( controller:'yourcontroller', action:'youraction')}',
data:{
param1:param1,
param2:param2
}
});
}
</g:javascript>
<input type="button" onclick="callMyAjax()"/>
如我所见,ajax-tags
由于效率低下问题已被弃用。他们建议 使用 Ajax 或原生 javascript。
无论如何,如果您仍然需要它们,可以使用作为迁移库的 grails 3 插件,但您也可以使用它:
compile 'org.grails.plugins:ajax-tags:1.0.0.RC1'