开发者

Ajax is not defined - Grails jQuery plugin

开发者 https://www.devze.com 2023-03-06 17:39 出处:网络
I\'m using jQuery in my project by the jQuery and jQuery-ui plugins. I have a simple form which I want to submit in Ajax call to the controller. The thing is, when I put the <g:su开发者_JAVA百科bmi

I'm using jQuery in my project by the jQuery and jQuery-ui plugins. I have a simple form which I want to submit in Ajax call to the controller. The thing is, when I put the <g:su开发者_JAVA百科bmitToRemote /> tag and then click it, firebug shows error that Ajax is not defined. What can I do to make it work?


Add this line to the layout file that your form GSP is using

<g:javascript library="jquery" plugin="jquery"/>

and the following to your grails-app/conf/Config.groovy

grails.views.javascript.library="jquery"

Grails 2.0.0

In Grails 2.0.0 the correct way to include JQuery is to use the new resources plugin by adding the following to the layout GSP

<html>
    <head>
        <!-- These 2 lines include JQuery -->
        <g:javascript library="jquery"/>
        <r:layoutResources/>

        <g:layoutHead/>
    </head>
    <body>
    </body>
</html>


you can also add <g:setProvider library="jquery"/> on the view needed

0

精彩评论

暂无评论...
验证码 换一张
取 消