Load Gravity Forms via AJAX

This example worked perfectly fine before the Gravity Forms 2.5 update:

Now it doesn’t seem to work. It loads the form but when you click submit, it does nothing. Does anyone what might have changed in the latest version?

The way the scripts are handled in Gravity Forms 2.5 did change and that is probably what is going on. Do you have any JavaScript errors in the developer console in the browser?

No console errors at all. I think it has something to do with gravity_form_enqueue_scripts. Do you have any info around what changed that could be causing this issue?

I don’t have any specific information around what changed. That was a bit of a customization that Steve put out all those years ago, and I’m not sure what changed that would make it stop. Gravity Forms support can’t provide support for customizations but you could open a ticket and see if someone knows exactly what is going on, or how to troubleshoot:

I opened a ticket with support and got a response today:

"It looks like this issue is related to 2.5 switching to the DOMContentLoaded event to trigger various form scripts. The product team will need to investigate this issue further. "

I will keep updating this thread with anything new I hear. I suspect this will become a bigger issue as more sites upgrade to version 2.5.

Thank you.

I heard back from Gravity Forms and they have a solution for this. I suspect it will get deployed in the near future.

2 Likes

I also have this issue, forms work when ajax is off, but don’t work when ajax is on. I need it to be on because my forms are embedded in a pop up which closes after submitting when it’s off. Hope there’s a fix soon.

The dev team made some changes to make this work but I just found out today that you need to add the following to functions.php to force the hooks JS to output no matter what.

add_filter( 'gform_force_hooks_js_output', '__return_true' );

Give it a try. It worked for me.

Thanks for the update!

I think I have the same issue… Just tried the code kahoots wrote and that just made all css disappear ib the forms admin site :joy:

We are running Gravity Forms version 2.5.3 and are not having any issues with the admin styles. This whole thread is about a very specific issue and will not solve all issues related to ajax. I suggest you open a ticket with support so they can help with your individual case.

I am having what I think is a related issue.

I have a GravityForm loaded in to an Elementor Popup vis a [SHORTCODE]
You can see the popup on this page (click POPUP at the bottom of the page)
https://scubamedical.com/link-generator

This worked perfectly in v2.4, but since upgrading to 2.5 it is not working.

Gravity Forms support advised upgrading to 2.5.3 which I have, but it still doesn’t work. Support said they don’t support embedding using shortcode in Elementor Popupsm which is a shame, so hopefully someone can help here.

I tried the gform_force_hooks_js_output filter but that doesn’t seem to fix it. In fact, even without this filter I could see plenty of JS added to the page for the form. It just seems like it never actually gets triggered.

We have the same problem. All forms load, but nothing happens when click submit with 2.5.2. We had to roll back to 2.4 versions to get our forms to work again.

Divi theme.
Cloudflare CDN.
rocket loader errors
javascript errors code moved to footer from header?
Ajax spinner not active.

1 Like

Good to know it’s not just me.

I think I will have to roll-back to 2.4 too.

I don’t need any of the fancy new features for now.

I think it’s a real shame that Gravity don’t want to look in to this. With their level of knowledge of their own product they could probably fix this in under 30 minutes.

As of version 2.5.3.1 the filter gform_force_hooks_js_output set to true is not needed because it’s being set in the gravity forms itself. I don’t know if this will change in the future.

2 Likes

Any chance you have conditional logic on your popup? I am having a similar issue and we have nailed down it is related to conditional logic.

If you drill down in your console, this is Display:none. Thats why it isnt showing. removing it makes it work fine. Same issue as me, but GF says its a plugin conflict.