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

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

问题描述

由于 g:remoteFunction 已弃用我应该使用什么?并请举例说明.

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

推荐答案

你应该使用你自己的 javascript AJAX 函数,因为它们提供了更多的灵活性

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

示例

曾经是:

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

应该是(例如在 JQuery 中):

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天全站免登陆