Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gravity Form loaded via AJAX not submitting

I have a gravity form that is being loaded by an AJAX function. For some reason, when I try to submit the form I get a 400 error /wp-admin/admin-ajax.php#gf_3:1

Following guides online I added gravity_form_enqueue_scripts(3, true); to my header.php which has not solved the issue.

The form works fine in the preview page. I've tested multiple forms and multiple functions, however none of my forms will submit if they were loaded via AJAX.

like image 519
laudx Avatar asked Sep 13 '25 13:09

laudx


1 Answers

I spent many hours on this problem. I'm using Gravity Forms 2.5.1

It turns out that the `DOMContentLoaded' event that is loaded with the form was not being triggered.

In my function that calls the form, I manually triggered the event and now it works as expected.

    window.document.dispatchEvent(new Event("DOMContentLoaded", { bubbles: true, cancelable: true }));```
like image 186
Squivo Avatar answered Sep 16 '25 13:09

Squivo