Forgot Your Password?

© ProximaStudy 2024. All rights reserved

We use cookies to enhance your experience. By continuing to visit this site, you agree to our Cookies Policy

}, 10); } // Close Modal function closeWarningModal() { $modal.removeClass('show'); setTimeout(() => { $modal.addClass('hidden'); }, 1000); $emailInput.val(''); window.location.reload(); } // Close Modal when clicking outside document.addEventListener("click", function (event) { let modal = document.getElementById("warningModal"); if (!modal.classList.contains("hidden") && event.target === modal) { closeWarningModal(); } }); $form.on('submit', function(event) { event.preventDefault(); const formData = new FormData($form[0]); // $.ajax({ // url: $form.attr('action'), // method: 'POST', // data: formData, // contentType: false, // processData: false, // headers: { // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') // }, // success: function(data) { // console.log('errorrrrrrrrrrrr',messages[0]) // if (data.errors) { // $.each(data.errors, function(field, messages) { // if (field === 'email') { // console.log('errorrrrrrrrrrrr',messages[0]) // $('#error').text(messages[0]); // } // }); // } // else if (data.status === 'success') { // $modalMessage.text(data.message); // $modalMessage.removeClass('text-red-500').addClass('text-green-500'); // showWarningModal(); // } else { // window.location.reload() // } // }, // }); $.ajax({ url: $form.attr('action'), method: 'POST', data: formData, contentType: false, processData: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(data) { console.log('data',data) if (data.status === 'success') { $modalMessage.text(data.message); $modalMessage.removeClass('text-red-500').addClass('can-edu-p'); showWarningModal(); } else { window.location.reload() } }, error: function(xhr, status, error) { if (xhr.status === 422) { try { const data = JSON.parse(xhr.responseText); if (data.errors) { $.each(data.errors, function(field, messages) { if (field === 'email') { $('#errordiv').removeClass('hidden') console.log('Error with email:', messages[0]); $('#error').text(messages[0]); } }); } } catch (e) { console.error('Error parsing the response:', e); $('#error').text('An unexpected error occurred.'); } } else { console.error('AJAX error:', error); $('#error').text('An error occurred while processing your request.'); } } }); }); window.closeWarningModal = closeWarningModal; });