1

I am calling ajax function

$.ajax({
     url: $.grails.createLink('class', 'action'),
     data: {id: id1},
     async: false
});

so I am calling grails method here

def action = {

} 

now at the end of this action method if I don't return anything I get js error 'Sorry, Error occurred' so explicitly I specified 'render ""' at the end of action method.

Is there any way to avoid render?

4

2 回答 2

2

如果您不返回任何内容,grails 将尝试渲染视图grails-app/views/controller/action.gsp

我希望这不存在,所以你会得到一个 404

你可以添加一个空视图、render一个空白模板,或者做你正在做的事情(最短的选项)

于 2013-08-07T18:07:42.097 回答
0
def action = {
    render "ok"
}

应该管用

于 2013-08-11T21:41:20.137 回答