简体   繁体   中英

Returning string to an ajax call in grails

I have a function sampleFunction() in my Groovy Controller class which I access using an Ajax call in my gsp as

var result = ${remoteFunction(controller: 'mycontroller', action: 'sampleFunction',
                                  update: 'none',
                                   params:'\'id=\'+id+\'&content=\'+content+\'&modSubj=\'+modSubj')}

How do I return a string from sampleFunction() so that the variable result has the returned value. Please help.

A Grails Controller action can call render directly to return some text in the response instead of using a GSP.

def sampleFunction() {
    render 'somestring'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM