I was using grails 1.3.4 for my project and everything was working fine until I decided to migrate my project to grails 2.0.3.
The render as JSON method was working fine for me for every AJAX call made by me through the gsp page via javascript. But now it is not working.
The code I am using for the call is :
Javascript in my GSP page:
var url = "${createLink(controller:'user',action:'someAction')}";
$.get(url,function(data){
if (data.results != "") {
alert(data.results);
}
});
Code in my controller:
import grails.converters.JSON
....
....
def someAction = {
def data = [results:"Ajax call working"]
render data as JSON
}
the above code was working perfectly for me in grails 1.3.4 but now I am getting the following error
No signature of method: grails.converters.JSON.render() is applicable
for argument types: (com.xxxx.yyy.UserController$_closure36)
values: [com.xxxx.yyy.UserController$_closure36@168d2e7]
Possible solutions: render(java.io.Writer),
render(javax.servlet.http.HttpServletResponse),
every(), find(), find(groovy.lang.Closure),
every(groovy.lang.Closure).
I am really stuck and don’t know what to do. Is there anything I am missing.
Also I am using
Groovy Version: 1.8.6 and JVM: 1.6.0_26
Try this pattern instead: