Loading Gravity Forms with AJAX by Shortcode

Hi,

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:

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

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.

/wp-admin/admin-ajax.php

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

/we-buy-motorhomes/wp-admin/admin-ajax.php#gf_2

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.

Thanks

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

This is now resolved.