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.
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 }));```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With