// Using jQuery for the website FRONT section: // We used TWO ways to operate the Dynamic Filters: statically for every filter using jQuery and dynamically from Admin Panel. Here we use the first way (for the 'fabric' filter): // Get all the filter values that the user have checked in the checkboxes -s in filters.blade.php function get_filter(class_name) { // get the filter values of a certain filter (e.g. the filter values of the 'fabric' filter which will be an array like ['cotton', 'polyester', ...] ) in filters.blade.php var filter = []; // get the filter values and store them in the array. Example: for the 'fabric' filter, store 'cotton', 'polyester' $('.' + class_name + ':checked').each(function() { // e.g. $('.fabric:checked') // select all the checked ':checked' checkboxes in filters.blade.php // https://www.w3schools.com/jquery/sel_input_checked.asp filter.push($(this).val()); // e.g. for the 'fabric' filter push the filter values like 'cotton', 'polyester' in the array }); console.log(filter); return filter; // filter is an array } // Add a Newsletter Subscriber email HTML Form Submission in front/layout/footer.blade.php when clicking on the Submit button (using an AJAX Request/Call) function addSubscriber() { // alert('test'); var subscriber_email = $('#subscriber_email').val(); // get the value that the user will enter in the field having that said HTML id Global Attribute // alert(subscriber_email); // Email validation in JavaScript // https://www.scaler.com/topics/email-validation-in-javascript/ var mailFormat = /\S+@\S+\.\S+/; // Regular Expression (RegExp/Regex) if (subscriber_email.match(mailFormat)) { // alert('Valid Email!'); } else { alert("Please enter a valid Email!"); return false; } $.ajax({ headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}, // X-CSRF-TOKEN: https://laravel.com/docs/9.x/csrf#csrf-x-csrf-token url : '/add-subscriber-email', // check this route in web.php type : 'post', data : {subscriber_email: subscriber_email}, // Sending name/value pairs to server with the AJAX request (AJAX call) success: function(resp) { // if the AJAX request / AJAX call is successful // alert(resp); if (resp == 'Email already exists') { // Check addSubscriber() method in Front/NewsletterController.php alert('Your email already exists for Newsletter Subscription!'); } else if (resp == 'Email saved in our database') { // Check addSubscriber() method in Front/NewsletterController.php alert('Thanks for subscribing!'); } }, error : function() { // if the AJAX request is unsuccessful alert('Error'); } }); } // jQuery $(document).ready(function() { // Show our Preloader/Loader/Loading Page/Preloading Screen ALL THE TIME FOR TESTING! // $('.loader').show(); // the ,