gform/ajax/post_submission_request

Description

The gform/ajax/post_submission_request filter is used to modify the AJAX response after a form is submitted via AJAX, but before the markup is reloaded. This filter allows developers to customize the response data before the markup is updated.

Usage

Asynchronous

Use this method when the function handling this event is asynchronous. This is useful when performing tasks that involve async operations, such as AJAX requests.

gform.utils.addAsyncFilter( 'gform/ajax/post_submission_request', async ( data ) => {
    // Custom logic here.
    return data;
} );

Parameters

NameTypeDescription
dataObjectThe data object passed to the filter.
data.formObjectA non-filterable object representing the submitted form.
data.submissionResultObjectA filterable object containing the result of the form submission.

Examples

Log the form and submission result objects to the console.

gform.utils.addAsyncFilter( 'gform/ajax/post_submission_request', async ( data ) => {
    console.log( 'Form Data:', data.form ); // Logs the form object.
    console.log( 'Submission Result:', data.submissionResult ); // Logs the submission result object.

    // Your custom logic.

    return data; // Return the modified data object.
} );

Placement

Reference the article Adding JavaScript Code to the Frontend of Your Site.

Source Code

This filter is located in assets/js/src/theme/submission/ajax.js.

Since

This filter was added in Gravity Forms 2.10.0.