0
我在Grails應用程序中使用Atmosphere插件向客戶端發送Ajax推送調用。基本的體系結構是,我在服務器中創建了一個循環,用於創建要推送給瀏覽器的數據,因此在每次迭代時都使用大氣的broadcast()方法將數據發送到客戶端。Grails氛圍插件問題
當我使用它的外循環,這樣它工作正常:
def builder = new JSONBuilder()
def jsonResult = builder.build{
artist = "incubus"
location = {
lat = 45.678909
lng = -14.45667
}
}
broadcaster['/atmosphere/recommend'].broadcast(jsonResult)
然而,當我以編程方式使用它的循環中,瀏覽器引發錯誤:指定了無效或非法串「代碼:」12,並且無法正常工作。
循環的一個簡單的例子如下:
[[lat:45.678909,lng:-14.45667],[lat:32.56433,lng:22.4566]].each{
def builder = new JSONBuilder()
def jsonResult = builder.build{
artist = "incubus"
location = {
lat = '"${it.lat}"'
lng = '"${it.lng}"'
}
}
broadcaster['/atmosphere/recommend'].broadcast(jsonResult)
}
任何想法,爲什麼會出現這種情況? 謝謝!