$(document).ready(function() { $('.campaign-form').parsley(); $('.campaign-form').on('submit', function(e) { e.preventDefault(); var buttonClicked = $('.campaign-submit-button'); var form = $('.campaign-form'); let values = Object.fromEntries(new FormData(e.target)) values.first_name = values.full_name values.mobile_number = values.phone let freshworksData = { contact: values } console.log("tettet", values) $.ajax({ type: 'POST', url: "http://3.19.245.174:8080/leads", data: JSON.stringify(freshworksData), dataType: "json", processData: false, cache: false, contentType: "application/json" }) $.ajax({ type: "POST", url: "ajax/campaign.php?mode=campaign", data: new FormData(this), dataType: "json", processData: false, cache: false, contentType: false, beforeSend: function() { buttonClicked.attr("disabled", true).html('Processing'); }, success: function(response) { if (response.status === 1) { window.location.replace("https://www.apainsurance.org/thankyou.php"); } else { swal.fire({ title: '
An error occurred. Please try again.
', type: 'error', allowOutsideClick: false, showCloseButton: true, focusConfirm: false, confirmButtonText: 'Ok!', }); } buttonClicked.attr("disabled", false).html('SUBMIT ' + ' '); } }); }) });