Description: Generates an AJAX request handler.
JavaDoc: Click here
Body content: JSP content.
Attributes:
| Name | Description | Data type | Required | Default value |
| id | the ID for this AJAX request | String | No | Auto-generated |
| ajaxEvent | the AJAX event to call | String | Yes | - |
| bindTo | if filled will bind this call to the given element and respective given event | String | No | - |
| serverCallMessage | The text for the server call | String | No | - |
| showCallMask | add a Mask to the current page while the server call is being executed | Boolean | No | True if serverCallMessage is set. False otherwise |
| bindTo | Allows binding of the dialog to an event of a given element, by it's ID. Notation: "componentID:event". | String | No | - |
| validationRequestFunction | Validation script called right before the ajax execution. The script must return a boolean type that's going to determine if the ajax request as the conditions to be executed. | String | No | - |
Examples:
#1: AJAX request with "Loading..." message.
Will report errors to the screen in a JavaScript Dialog window, or redirect to the next stage.
<dif:document>
<dif:ajaxRequest ajaxEvent="ajaxEventName" bindTo="triggerelementID:click" showCallMask="true">
<dif:success refreshComponentID="test" stageParameters="param=123" />
<dif:failure>The request failed with the following error:<br/>$result</dif:failure>
</dif:ajaxRequest>
</dif:document>
#2: AJAX request with a custom "Call in progress..." message.
Will report errors a specific div on the page, or refresh a partial page section (inner stage) on success. Since the success stage refresh is slow, we will show a message while it happens.
<dif:document>
<dif:component stageID="stageThatDisplaysSomeDynamicData" />
<div id="errorArea" style="display: none;"/>
<dif:ajaxRequest ajaxEvent="ajaxEventName" bindTo="triggerelementID:click" serverCallMessage="Call in progress...">
<dif:success refreshComponentID="stageThatDisplaysSomeDynamicData" stageParameters="afterUpdate=true"
loadingMessage="Updating data..." />
<dif:failure targetElementID="errorArea">
The request failed with the following error:<br/>$result
</dif:failure>
</dif:ajaxRequest>
</dif:document>
#3: AJAX request with no activity message (silent mode).
Will parse all error if existent, or redirect to a specific site in success.
<dif:document>
<dif:component stageID="stageThatDisplaysSomeDynamicData" />
<dif:ajaxRequest ajaxEvent="ajaxEventName" bindTo="triggerelementID:click" serverCallMessage="Call in progress...">
<dif:success executeJavaScript="true">
alert("Here we can insert whatever JS code we wish...");
alert("The AJAX results are here: " + result);
</dif:success>
<dif:failure targetElementID="errorArea">
The request failed with the following error:<br/>$result
</dif:failure>
</dif:ajaxRequest>
</dif:document>
See also: