1
一個Grails模板,我有更新在我看來,使用AJAX和JSON
<g:render template="/common/notifications" model="[userNotifications:userNotifications]" />
在JavaScript我有一個AJAX調用返回Notification
小號
控制器方法的JSON對象被稱爲是如下:
def getNotifications()
{
def userNotifications = Notification.findAllByUser(UserUtils.getCurrentUser())
render userNotifications as JSON
}
但我沒有線索如何獲得響應數據提供模板與模型
非常感謝任何幫助
啊對,所以我認爲它創造了'div'的事項,''的notificationContainer' id'說,然後在成功回調在JavaScript調用'$( '#notificationContainer')。html(data)'?這似乎工作,是做到這一點的正確方法?感謝您的幫助:) – 2013-05-03 17:28:10
是的,這是正確的 – 2013-05-03 18:20:20