我认为我有
<g:render template="/common/notifications" model="[userNotifications:userNotifications]" />
在javascript中,我有一个ajax调用来返回Notification的JSON对象

调用的 Controller 方法如下:

def getNotifications()
{
    def userNotifications = Notification.findAllByUser(UserUtils.getCurrentUser())

    render userNotifications as JSON
}

但我不知道如何获取响应数据以为模板提供模型

任何帮助深表感谢

最佳答案

代替渲染对象,而是渲染模板。让您的ajax期望HTML作为返回:

render(template: '/common/notifications', model: [userNotifications: userNotifications])

10-04 20:07