Loading Gravity Forms with AJAX by Shortcode


I am having issues with the form submission on my Gravity forms which I have loaded via AJAX.

On my loaded page, I have a button which triggers an AJAX event to fetch a template part which contains a shortcode for Gravity Forms.

On the main page I have this preloaded to ensure styling works and the JS output.

add_filter( 'gform_force_hooks_js_output', '__return_true' );
gravity_form_enqueue_scripts( 2, true ); // Form_Id = 2

In my Javascript file I have:

	url: VC.ajax_url,
	method: 'POST',
	async: false,
	data: {
		action: 'fetch_form',
	success: function( response ) {
		t.elements.results.html( response );

Now I have tested the form submission with AJAX=“true” and AJAX=“false”.

When I use AJAX=“false”, The URL the form is posted to below, except I only get a response of 0 displayed.


If I use AJAX=“true”, The URL the form is posted to is:


This then errors in console as it’s not a valid URL.

Can anyone point me in the right direction? I have checked StackOverflow and some posts on here which all have similar errors, but seem to be older versions?

I am up to date and currently using Gravity Forms Version 2.6.3.


Anyone able to point me in the right direction? GF support unable to support.

This is now resolved.