在foo动作的返回中,您可以将简单的html作为文本或渲染可以在视图中使用的某些对象。
这里有所有关于控制器的信息“渲染”
http://grails.org/doc/latest/ref/Controllers/render.html
你可以有一个与该数据将更新与它在那里工作。然后,您可以像通常那样使用JavaScript访问该“foo”div中的Html和数据。
例如:
Controller.groovy
// renders text to response
render '<div id="bar" onclick="alert($('bar').val())>some text</div>'
View.gsp
//Makes the call and updates foo
<div onload="${remoteFunction(action:"foo", update:"foo"...)}" ...>
<div id="foo" name="foo"></div>
输出
<div onload="theAjaxJavascriptFunctionThatGrailsWillInject" ...>
<div id="foo" name="foo">
<div id="bar" onclick="alert($('bar').val())">some text</div>
</div>
我你从Controller.grooy返回一些对象,然后你有E要像对待这你View.gsp
//Makes the call and updates foo
<div onload="${remoteFunction(action:"foo", update:"foo"...)}" ...>
<div id="foo" name="foo">
${myObject.theValueIWant}
</div>
我添加了一个JavaScript警告,但你可以做到这一点,你喜欢的方式,有很多方法可以做到这一点。
希望它有帮助:)