Ajax Gravity Forms ((link)) May 2026

// Tell Gravity Forms to process the submission but not to output anything $_POST['gform_submit'] = $form_id; $result = GFFormDisplay::process_form( $form_id, $form );

var formData = new FormData(this); formData.append('action', 'my_gf_submit_form'); formData.append('security', my_ajax_obj.nonce); $.ajax({ url: my_ajax_obj.ajax_url, type: 'POST', data: formData, contentType: false, // Important for file uploads processData: false, // ... rest of AJAX config }); ajax gravity forms

However, this built-in solution, while powerful, is the "lowest common denominator." It works reliably, but it lacks customization. The confirmation message fades in, the errors appear, but you have limited control over what happens next . What if you want to redirect to a custom "thank you" page using AJAX ? What if you want to close a modal window upon successful submission? What if you need to track the submission in Google Analytics? // Tell Gravity Forms to process the submission

function my_gf_ajax_scripts() { if ( has_shortcode( get_post()->post_content, 'gravityform' ) ) { wp_enqueue_script( 'my-gf-ajax', get_template_directory_uri() . '/js/gf-ajax.js', array('jquery'), '1.0', true ); wp_localize_script( 'my-gf-ajax', 'my_ajax_obj', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'gf_ajax_nonce' ), ) ); } } add_action( 'wp_enqueue_scripts', 'my_gf_ajax_scripts' ); This script will find your form (using its ID, e.g., gform_1 ), override the submit behavior, and send the data via AJAX. What if you want to redirect to a

Google's reCAPTCHA expects a normal form submission in many configurations. When using AJAX, you must ensure the reCAPTCHA token is included in your AJAX data and that you initialize reCAPTCHA on the new content if the form is dynamically loaded.