apex_generate_ajax_handler
Generate a server-side PL/SQL AJAX callback for Oracle APEX, callable from client-side JavaScript. Automatically adds the JS caller function to the page for immediate use.
Instructions
Create an AJAX callback process (PL/SQL) callable from client-side JS.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_id | Yes | Page that owns this callback. | |
| plsql_code | Yes | PL/SQL block that runs server-side. Access page items via bind variables: :P10_ITEM_NAME Return JSON via: apex_json.open_object; apex_json.write('key', val); apex_json.close_object; Example: DECLARE v_count NUMBER; BEGIN SELECT COUNT(*) INTO v_count FROM my_table WHERE status = :P10_STATUS; apex_json.open_object; apex_json.write('count', v_count); apex_json.write('status', 'success'); apex_json.close_object; END; | |
| auto_add_js | No | Automatically add the generated JavaScript caller function to the page via apex_add_page_js() (default True). When True, the function will be available at runtime without any additional steps. Set to False if you want to manually review and modify the JS before adding it to the page. | |
| input_items | No | List of page item names to send to server (e.g., ["P10_SEARCH", "P10_STATUS"]). | |
| return_json | No | Whether the callback returns JSON (default True). | |
| callback_name | Yes | UPPERCASE name for the callback (e.g., "SAVE_RECORD", "SEARCH_DATA"). Called from JS as: apex.server.process('CALLBACK_NAME', {...}) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |