FLBuilderAJAX class handles frontend AJAX requests for the Beaver Builder interface. It provides a secure way to execute builder operations without using WordPress admin AJAX.
Overview
TheFLBuilderAJAX class is defined in classes/class-fl-builder-ajax.php and provides:
- Secure frontend AJAX handling
- Action registration system
- User authentication and capability checks
- Nonce verification
- Method routing
Why Frontend AJAX?
Beaver Builder uses frontend AJAX instead ofwp-admin/admin-ajax.php because:
- Shortcode compatibility - Some shortcodes only work on the frontend
- Theme context - Preview with actual theme styles and scripts
- Performance - Lighter than loading the entire admin
- Accuracy - What you see is what you get
class-fl-builder-ajax.php:3-12
Class Methods
init()
Initializes the AJAX handler.wp action to run AJAX handlers.
Source: class-fl-builder-ajax.php:30
add_action()
Registers a new AJAX action.The AJAX action name (e.g.,
'save_settings')The static method to call (e.g.,
'FLBuilderModel::save_settings')Array of POST parameter names to pass to the method
class-fl-builder-ajax.php:54
remove_action()
Removes a registered AJAX action.The action name to remove
class-fl-builder-ajax.php:69
Registered Actions
The following AJAX actions are registered by default:FLBuilderModel Actions
Node management actions
Node management actions
get_node_settings- Get settings for a nodedelete_node- Delete a nodedelete_col- Delete a columnreorder_node- Change node positionreorder_col- Change column positionmove_node- Move node to new parentmove_col- Move column to new parentresize_cols- Resize column widthsreset_col_widths- Reset columns to equal widthresize_row_content- Resize row content width
Settings actions
Settings actions
save_settings- Save node settingsverify_settings- Verify settings before savesave_layout_settings- Save layout settingssave_global_settings- Save global settingssave_color_presets- Save color presets
Layout actions
Layout actions
save_layout- Save and optionally publish layoutsave_draft- Save draft layoutclear_draft_layout- Clear draft dataapply_template- Apply a templateapply_user_template- Apply a user templateduplicate_post- Duplicate a post
FLBuilderAJAXLayout Actions
Rendering actions
Rendering actions
get_layout- Get entire layout HTMLrender_layout- Render entire layoutrender_node- Render a single noderender_new_row- Render a new rowrender_new_module- Render a new modulecopy_row- Copy a rowcopy_col- Copy a columncopy_module- Copy a module
class-fl-builder-ajax.php:82-150
Security
All AJAX requests are secured with:1. User Authentication
2. Nonce Verification
3. Capability Check
Making AJAX Requests
From JavaScript, use the builder’s AJAX helper:FLBuilder.ajax() method automatically includes:
- The builder nonce
- Post ID
- Error handling
- Loading indicators
Custom AJAX for Modules
AJAX Hooks
Beaver Builder provides hooks to modify AJAX behavior:Before Action
After Action
Filter Response
Response Format
AJAX responses are JSON-encoded:Success Response
Error Response
Usage Examples
Adding a Custom AJAX Action
Calling from JavaScript
Related Classes
FLBuilderAJAXLayout
Layout rendering AJAX operations
FLBuilderModel
Data model with AJAX-callable methods
AJAX Operations
Learn about AJAX in custom modules
Hooks & Filters
Complete hooks reference
Best Practices
For custom module AJAX, use WordPress’s standard
wp_ajax_ hooks instead of FLBuilderAJAX.Source Code Reference
- File:
classes/class-fl-builder-ajax.php - File:
classes/class-fl-builder-ajax-layout.php(rendering) - Since: Version 1.7
- Version: 2.10.1.1