1jQuery(document).ready(function($) { 2 3/* Interviewer */ 4$("#openModalBtn3").on('click',function(e){ 5 e.preventDefault(); 6 $("#interviewerModal").fadeIn(); 7}); 8 9/* Close Modal */ 10 11 $('#closeModalBtn3').click(function() { 12 $('#interviewerModal').fadeOut(); // Hide the modal 13 $('#interviewer-form')[0].reset(); // Reset the form fields 14 $('#form-message3').html(''); // Clear any messages 15 }); 16/* end close modal */ 17 18 /* Handle the Interviewer form submission via AJAX */ 19 $('#interviewer-form').submit(function(e) { 20 e.preventDefault(); // Prevent normal form submission 21 22 var interviewerName = $('#interviewer_name').val(); // Get the company name 23 var interviewerDescription = $('#interviewer_description').val(); // Get the optional description 24 var formMessage3 = $('#form-message3'); 25 26 // Check if company name is empty 27 if (interviewerName === "") { 28 formMessage3.html('<p style="color: red;">Please enter an interviewer name.</p>'); 29 return; 30 } 31 32 /* Clear any previous messages */ 33 formMessage3.html(''); 34 35 // Send the data via AJAX to admin-ajax.php 36 $.ajax({ 37 url: interviewerAjax.ajax_url, 38 method: 'POST', 39 data: { 40 action: 'add_interviewer_term', // Action hook to handle the request 41 nonce: interviewerAjax.nonce, // Security nonce 42 interviewer_name: interviewerName, // Company name to add 43 interviewer_description: interviewerDescription // Description (optional) 44 }, 45 success: function(response) { 46 if (response.success) { 47 // Show success message 48 formMessage3.html('<p style="color: green;">Interviewer added successfully!</p>'); 49 50 // Refresh the checkbox list (by fetching new terms) 51 fetch_interviewer_terms(); 52 53 // Close the modal after successful submission 54 $('#interviewerModal').fadeOut(); 55 56 // Reset the form fields when the modal is closed 57 $('#interviewer-form')[0].reset(); 58 $('#form-message3').html(''); // Clear any messages 59 } else { 60 // Show error message 61 formMessage3.html('<p style="color: red;">' + response.data + '</p>'); 62 } 63 }, 64 error: function() { 65 formMessage3.html('<p style="color: red;">An error occurred. Please try again.</p>'); 66 } 67 }); 68 }); /* end interviewer submission */ 69 70 71 /* Function to fetch and refresh the list of interviewer terms (checkboxes) */ 72 function fetch_interviewer_terms() { 73 $.ajax({ 74 url: interviewerAjax.ajax_url, 75 method: 'GET', 76 data: { 77 action: 'get_interviewer_terms' // Action hook to fetch the terms 78 }, 79 success: function(response) { 80 if (response.success) { 81 // Replace the checkbox list with the updated list 82 $('#interviewer').html(response.data); 83 } 84 }, 85 error: function() { 86 alert("Error fetching terms."); 87 } 88 }); 89 } /* End */ 90 91}); // end jquery
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.