Ajax Gravity Forms Repack May 2026
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 });
function my_gf_ajax_submit_handler() { // Verify nonce if ( ! wp_verify_nonce( $_POST['security'], 'gf_ajax_nonce' ) ) { wp_die('Security check failed'); } $form_id = intval( $_POST['form_id'] ); $form = GFAPI::get_form( $form_id ); ajax gravity forms
Traditional AJAX using serializeArray() does not handle file inputs. For forms with file uploads, you need to use the FormData API: var formData = new FormData(this); formData
For WordPress site owners, this traditional, synchronous form submission has long been the default behavior of Gravity Forms, the premium plugin powering millions of websites. It works. It's reliable. But in an era of single-page applications and instant feedback, the full-page reload feels clunky, disorienting, and slow. For forms with file uploads, you need to
wp_send_json_error( array( 'validation_html' => $validation_html ) ); } else { // Success! Define a redirect URL (from confirmation or custom) $confirmation = GFFormDisplay::handle_confirmation( $form, $entry, false ); $redirect_url = is_array( $confirmation ) && isset( $confirmation['redirect'] ) ? $confirmation['redirect'] : home_url( '/thank-you/' );