由于grails 2.4.X中的g:remoteFunction已被弃用,我应该使用什么呢? [英] Since g:remoteFunction in Grails 2.4.X is deprecated what should i use instead?

查看:122
本文介绍了由于grails 2.4.X中的g:remoteFunction已被弃用,我应该使用什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于已弃用 g:remoteFunction 我应该用什么来代替?请给出一个例子。 您应该使用自己的JavaScript AJAX函数,因为它们提供了更多的灵活性。



举例

曾经是:

 < input type =buttonvalue =go! onclick =$ {g.remoteFunction(controller:'my',action:'go',params:[..])}/> 

应该是(例如 JQuery ) :

 < g:javascript> 
函数go(){
$ .ajax({
url:'$ {g.createLink(controller:'my',action:'go',params:[..]) }',
data:{param1:param1}
});
}
< / g:javascript>

< input type =buttonvalue =go!的onclick = 去()/>


Since g:remoteFunction is deprecated what should I use instead? And please give an example.

解决方案

you should use your own javascript AJAX functions, as they provide way more flexibility

EXAMPLE

used to be:

<input type="button" value="go!" onclick="${g.remoteFunction( controller:'my', action:'go', params:[..] )}"/>

should be (for example in JQuery):

<g:javascript>
  function go(){
    $.ajax({ 
      url:'${g.createLink( controller:'my', action:'go', params:[..] )}',
      data:{ param1:param1 }
    });
  }
 </g:javascript>

 <input type="button" value="go!" onclick="go()"/>

这篇关于由于grails 2.4.X中的g:remoteFunction已被弃用,我应该使用什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆