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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog