Sripaul
Sripaul

Reputation: 2235

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.

Upvotes: 0

Views: 2943

Answers (1)

Ken Liu
Ken Liu

Reputation: 22914

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

def sampleFunction() {
    render 'somestring'
}

Upvotes: 5

Related Questions