Can anyone help me to show show how to submit an Hubspot form using Ajax without page redirection, i am storing some values on JS if page redirects, it will go. if any one have any ideas please reply
Hubspot advanced form options Adding inlineMessage as an option in your form embed code like below will keep it inside. You can even add a function in JS after the submission. Between the two of these you shoudl be able to submit the form and stay on the page and start any JS you want after the form is submitted.
hbspt.forms.create({
portalId: 'xxxxxx',
formId: 'xxxxxx',
inlineMessage: 'Here is a fake inline message',
onFormSubmit: function($form) {
/* insert JS here maybe hiding the message, or making the message be a please wait one moment*/
console.log('the form was just submitted');
}
});
This code is not working for me Please help me out of this problem. When the form is submitted I want to show both success message and form on the website . But now only showing the success message. Please give me a solution for this.
@neena since this original post, HubSpot has added support for CORS to the submit form endpoint so you can easily do an XHR/Ajax submission without issue. The latest documentation for this endpoint is here: https://developers.hubspot.com/docs/methods/forms/submit_form
Hi ! I am encountering the same problem at the moment can please show me the code you've been using to submit your own form and hidding the one from HS ? I can't make it to work.