1jQuery(document).ready(function ($) { 2 $('#submit-form').on('click', function (e) { 3 e.preventDefault(); // Prevent the default form submission 4 5 // Remove previous error messages 6 $('.error-message').remove(); 7 8 // Check required fields 9 var requiredFields = ['email', 'FNAME', 'LNAME', 'ROLE', 'ORG']; 10 var isValid = true; 11 12 for (var i = 0; i < requiredFields.length; i++) { 13 var fieldId = requiredFields[i]; 14 var fieldValue = $('#' + fieldId).val().trim(); 15 16 if (fieldValue === '') { 17 $('#' + fieldId).after('<span class="error-message">This field is required.</span>'); 18 isValid = false; 19 } else { 20 // Remove the error message if the field is not empty 21 $('#' + fieldId).next('.error-message').remove(); 22 } 23 } 24 25 if (isValid) { 26 var formData = $('#mailchimp-form').serialize(); 27 const detailedUserAnswers = JSON.parse(sessionStorage.getItem('userAnswers') || '[]'); 28 // const progressHTML = sessionStorage.getItem('progressHTML'); 29 var scoreProgressText = $('.score-progress-sec h1').text(); 30 var progressData = []; 31 32 $('#progress-secbar li').each(function() { 33 var categoryDiv = $(this).children().first(); // Assuming the category is the first child 34 var progressBar = $(this).find('.progress-bar'); 35 36 // Extract the color class; assumes it's the first class of the progress-bar element 37 var colorClasses = progressBar.attr('class').split(' '); 38 var color = colorClasses.length > 1 ? colorClasses[1] : ''; // adjust based on your class naming 39 40 // Extracting the category; assumes it's the text of the first <p> tag within the div 41 var category = categoryDiv.find('p').text(); 42 43 44 var data = { 45 category: category, 46 color: color, 47 ariaValuenow: progressBar.attr('aria-valuenow'), 48 ariaValuemin: progressBar.attr('aria-valuemin'), 49 ariaValuemax: progressBar.attr('aria-valuemax'), 50 width: progressBar.css('width'), 51 52 }; 53 progressData.push(data); 54 }); 55 var resultProgress = { 56 scoreProgressText: scoreProgressText, 57 progressData: progressData 58 }; 59 60 61 62 63 // Stringify and encode progressData 64 var encodedProgressData = encodeURIComponent(JSON.stringify(resultProgress)); 65 66 67 // formData += '&detailedUserAnswers=' + encodeURIComponent(JSON.stringify(detailedUserAnswers)); 68 formData += '&detailedUserAnswers=' + encodeURIComponent(JSON.stringify(detailedUserAnswers)); 69 // formData += '&progressHTML=' + encodeURIComponent(progressHTML); 70 // Append progressData to formData 71 formData += '&progressData=' + encodedProgressData; 72 73 74 75 // AJAX request 76 $.ajax({
77 type: 'POST', 78 url: custom_mailchimp_ajax.ajax_url, 79 data: 'action=custom_mailchimp_submit&' + formData, 80 beforeSend: function () { 81 // Code to be executed before the request is sent 82 $('.loader_mailchimp').show(); 83 $('.loader_mailchimp').text('Please Wait...'); 84 }, 85 success: function (response) { 86 console.log(response); 87 88 if(response.data.status){ 89 $('.loader_mailchimp').show(); 90 $('.loader_mailchimp').text('Please Wait...'); 91 $('.quiz-form').hide(); 92 $('.quiz-progress').show(); 93 94 $('#ans_ques_digital_sec h2').text('View your digital maturity score below.'); 95 $('#ans_ques_digital_sec p').text('We will be in touch soon to further understand how we can help your business.'); 96 97 $('html, body').animate({ scrollTop: $('.quiz-progress').offset().top }, 'slow'); 98 99 }else{ 100 101 $('.loader_mailchimp').hide(); 102 $('.loader_mailchimp').text(''); 103 alert(response.data.message); 104 105 } 106 107 // Handle the response (e.g., display a success message) 108 }, 109 error: function (xhr, status, error) { 110 console.error('AJAX Error:', status, error); 111 }, 112 }); 113 } else { 114 // Scroll up to the top of the form 115 $('html, body').animate({ scrollTop: $('#mailchimp-form').offset().top }, 'slow'); 116 } 117 }); 118 119 // Remove error messages when the user starts typing 120 $('#mailchimp-form input').on('input', function () { 121 $(this).next('.error-message').remove(); 122 }); 123});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.