7.7.1.4 Ajax Events 2.3.8

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 7.7.1.4 Ajax Events - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 2.3.8 ## 7.7.1.4 Ajax Events 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:
    <g:remoteLink action="show"
                  id="1"
                  update="success"
                  onLoading="showProgress()"
                  onComplete="hideProgress()">Show Book 1</g:remoteLink>
The above code will execute the "showProgress()" function which may show a progress bar or whatever is appropriate. Other events include: `onSuccess` - The JavaScript function to call if successful `onFailure` - The JavaScript function to call if the call failed `on_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 initialise `onLoading` - The JavaScript function to call when the remote function is loading the response `onLoaded` - The JavaScript function to call when the remote function is completed loading the response `onComplete` - The JavaScript function to call when the remote function is complete, including any updates You can simply refer to the `XMLHttpRequest` variable to obtain the request:
    <g:javascript>
        function fireMe(event) {
            alert("XmlHttpRequest = " + event)
        }
    }
    </g:javascript>
    <g:remoteLink action="example"
                  update="success"
                  onFailure="fireMe(XMLHttpRequest)">Ajax Link</g:remoteLink>
| Quick Reference (hide)