document.addEventListener('wpcf7submit', function(event) {
// Replace '1234' with your numeric form ID from Contact Form 7
if (event.detail.contactFormId === '22812ba') {
// Create FormData object from the form element
var formData = new FormData(event.detail.contactForm.form);
// Send form data to Salesforce or any other endpoint
fetch('https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8&orgId=00DHp000001t1n8', {
method: 'POST',
body: formData,
})
.then(function(response) {
if (response.ok) {
alert('Form successfully Submitted!');
} else {
alert('There was an issue submitting your form.');
}
})
.catch(function(error) {
alert('An error occurred while submitting your form.');
});
}
}, false);