Hubspot forms refershing the page on submission instead of redirecting to an external URL



We are facing an issue which is related to the Hubspot forms. We are using two different forms embedded code and written a JavaScript page redirect code to the embedded code. But sometimes Forms does not behaving properly and just refreshing page instead of redirecting to the external URL.

Following is the example of code.

onFormSubmit: function($form){
setTimeout( function() {
var formData = $form.serialize();
window.location = "external-url" + formData;
}, 250 );

Can somebody help us to fix the above problem.



Hi @dev1penguin,

I'm not totally clear on what this is supposed to be doing; are you setting window.location to a the string concatenation of external-url and the serialized form data? Or is external-url just a stand in for your actual external URL?

I'm wondering if the default redirect behavior of the form is sometimes executing before your timeout funcion executes. You'd likely be better off setting the redirectUrl parameter to your external URL, and then appending the query parameter info you need to include to that string so that it's included in the redirect.