var $ = jQuery.noConflict(); $(document).ready(function() { var $ajaxForm = $('.form-widget:not(.customjs)'); if ($ajaxForm.length < 1) { return true; } $ajaxForm.each(function () { var element = $(this), elementForm = element.find('form'), elementFormId = elementForm.attr('id'), elementAlert = element.attr('data-alert-type'), elementResult = element.find('.form-result'); // CSS Amendments if (!elementAlert) { elementAlert = 'notify'; } sendEmail = function(contactInfo) { $(elementForm).find('.form-process').fadeIn(); $( "#sendEmailButton" ).addClass( "formSent" ); //UAT // var uri = "https://web.api.uat.cloudigo.app/business-contact"; //Live var uri = "https://web.api.cloudigo.app/business-contact"; var toSend = {}; toSend.page = contactInfo[1]; toSend.name = contactInfo[2]; toSend.query_type = contactInfo[3]; toSend.fname = contactInfo[4]; toSend.email = contactInfo[5]; toSend.mobile = contactInfo[6]; toSend.country_code = contactInfo[7]; toSend.message = contactInfo[8]; toSend.ecid = (ecid == "=" ? "" : ecid); toSend.employees = contactInfo[9]; toSend.token = contactInfo[10]; data = JSON.stringify(toSend); jQuery.ajax({ url: uri, data: data, method: 'POST', contentType : 'application/json', success: function (data) { $(elementForm).find('.form-process').fadeOut(); elementResult.removeClass('alert-danger alert-success').addClass('alert ' + "alert-success").html(data.message).slideDown(400); $("#template-contactform").trigger("reset"); // Disabling the button gets overwrited, thus, styling takes place instead $( "#sendEmailButton" ).removeClass( "formSent" ); } , error: function (data) { $(elementForm).find('.form-process').fadeOut(); elementResult.removeClass('alert-danger alert-success').addClass('alert ' + "alert-danger").html("Message not sent. Please try again later.").slideDown(400); if (typeof data.responseJSON !== 'undefined' && typeof data.responseJSON.message !== 'undefined') { console.log(data.responseJSON.message); } } }) } }) });