Ajax Gravity Forms ((hot)) [VERIFIED ✮]
jQuery(document).ready(function($) { var formId = 1; // Change this to your form's ID var $form = $('#gform_' + formId); $form.on('submit', function(e) { e.preventDefault(); // Stop normal submission
if ( empty( $result['is_valid'] ) ) { // Validation failed. Get the validation HTML. ob_start(); GFFormDisplay::get_form( $form_id, true, true ); $validation_html = ob_get_clean(); ajax gravity forms
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 }); jQuery(document)
In the early days of the web, submitting a form was a dramatic event. You filled out your name, email, and message, clicked "Submit," and then... the screen went white. The browser churned, the page reloaded, and you found yourself either staring at a "Thank You" message at the top of a freshly rendered page or, more frustratingly, back at the same form, squinting to see which red error message had appeared. rest of AJAX config }); In the early
Последние комментарии