Using AJAX reduces the amount of unnecessary data traffic with the server thereby speeding up application processing. It allows individual data components on a page to be updated without the need to refresh the entire page.
Figure 1: AJAX event interface.
The following events are available in ScriptCase.
Only the onClick event is available to Grid applications.
See the example below: The user field is validated against a database (table). For valid users it returns the name. For invalid users a message is displayed.
Example:
1 - Select the field and the event used by the AJAX process, (in PHP code). Passing parameters is optional.
Figure 2: Selecting fields and events for AJAX processing.
2 -Enter the PHP business rule in the PHP editor. The code is processed by the Server and the XML result is sent to the browser.
Figure 3: Programming PHP with AJAX.
1. PHP editor - Use it to type in your PHP code.
2. Insert Code - ScriptCase provides you with a number of predefined blocks of code that can be inserted into the PHP editor and then amended accordingly.
3. Parameters (Fields) - Use this to create parameters retrieving field values.
Any event can use pre-defined functions (macros) that are available in Scriptcase. These functions are called "Scriptcase Macros".