6.7.1.4 Ajax事件 - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: null
6.7.1.4 Ajax事件
Specific JavaScript can be called if certain events occur, all the events start with the "on" prefix and let you give feedback to the user where appropriate, or take other action:The above code will execute the "showProgress()" function which may show a progress bar or whatever is appropriate. Other events include:
当某个事件发生时,特定的JavaScript将会被调用到,所有这些事件都是以"on"为前缀,并且合适地反馈给用户或者其他处理,比如:<g:remoteLink action="show" id="1" update="success" onLoading="showProgress()" onComplete="hideProgress()">Show Book 1</g:remoteLink>
onSuccess- The JavaScript function to call if successfulonFailure- The JavaScript function to call if the call failedon_ERROR_CODE- The JavaScript function to call to handle specified error codes (eg on404="alert('not found!')")onUninitialized- The JavaScript function to call the a Ajax engine failed to initialiseonLoading- The JavaScript function to call when the remote function is loading the responseonLoaded- The JavaScript function to call when the remote function is completed loading the responseonComplete- The JavaScript function to call when the remote function is complete, including any updates
XmlHttpRequest object you can use the implicit event parameter e to obtain it:<g:javascript> function fireMe(e) { alert("XmlHttpRequest = " + e) } } </g:javascript> <g:remoteLink action="example" update="success" onSuccess="fireMe(e)">Ajax Link</g:remoteLink>
<g:remoteLink action="show" id="1" update="success" onLoading="showProgress()" onComplete="hideProgress()">Show Book 1</g:remoteLink>
onSuccess- 成功时要调用的JavaScript函数onFailure- 失败时要调用的JavaScript函数on_ERROR_CODE- 处理特定的错误编码(比如on404="alert('not found!')")时要调用的JavaScript函数onUninitialized- Ajax引擎初始化失败时要调用的JavaScript函数onLoading- 远程调用正在加载响应时要调用的JavaScript函数onLoaded- 远程调用已经加载完响应时要调用的JavaScript函数onComplete- 远程调用完全结束(包括更新内容)时要调用的JavaScript函数
XmlHttpRequest对象,你可以使用隐式的事件参数e来获取它:<g:javascript> function fireMe(e) { alert("XmlHttpRequest = " + e) } } </g:javascript> <g:remoteLink action="example" update="success" onSuccess="fireMe(e)">Ajax Link</g:remoteLink>

