weixin_33696822 2012-03-05 01:41 采纳率: 0%
浏览 39

Grails Ajax功能

I'm fairly new to Grails and today was following a tutorial on spicing up Grails with Ajax (prototype). The tutorial was simple quote of the day Grails app that would asynchronously fetch random quote from the db. I've spent almost 3 hours getting ajax to work, finally got it to work with weird outcome. Basically, ajax wouldn't work unless I put the following two lines to both gsp of the view and gsp of the layout:

<g:javascript library="prototype" />
<r:layoutResources />

I tried to put the above lines into either one, but that wouldn't work. It had to be in both places. Is that the expected behavior of grails?

  • 写回答

1条回答 默认 最新

  • csdnceshi62 2012-03-05 10:40
    关注

    That's not the expected behaviour. Get the latest Grails version and use jQuery as described in the documentation: http://grails.org/doc/latest/guide/theWebLayer.html#6.7%20Ajax

    Prototype can also be used, but jQuery is preferred since Grails 2.0.

    A simple <g:javascript library="jquery" /> should then do the trick.

    BTW: V2.0 is pretty new. Most tutorials and books are still refering to 1.3.7 . So if you run into problems, check the really fine manual. But don't get me wrong: most of the books and tutorials are still great and valuable - you should just consult the manual, too!

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?