@dovid @צדיק-תמים
תודה, השרת שלי מחזיר שגיאה, הוספתי את זה:
$.ajax({
type: "POST",
url: "validation.php",
data: {
'form': currentTab,
'formData': formData
},
success: function(data) {
console.log('Server response: ', data); // Debugging line
// Check if there are any errors
if (data.errors && Object.keys(data.errors).length > 0) {
// Log the errors for debugging
console.error('Validation errors:', data.errors);
// Display each error using the toast plugin
for(var key in data.errors) {
if(data.errors.hasOwnProperty(key)) {
$.toast({
heading: 'Error',
text: data.errors[key], // get the error message using the key
hideAfter: 8000, // in milli seconds
showHideTransition: 'slide',
stack: 3,
position: 'mid-center',
icon: 'warning',
bgColor: '#FFC800',
loaderBg: '#FF9F00', // To change the background
textColor: 'white',
textAlign: 'left'
});
}
}
} else if (data.success) {
// If success is true, display success message and/or move to next tab
console.log('Form submission successful');
// Your code to switch to the next tab or show a success message
}
},
error: function(jqXHR, textStatus, errorThrown) {
// Handle server errors, network errors, etc
console.error('AJAX error: ', textStatus, errorThrown);
$.toast({
heading: 'Error',
text: '.אירעה שגיאה בתהליך העיבוד של הטופס, בבקשה נסה שוב',
hideAfter: 8000,
showHideTransition: 'slide',
stack: 3,
position: 'mid-center',
icon: 'error',
bgColor: '#FF0000',
loaderBg: '#FF9F00',
textColor: 'white',
textAlign: 'left'
});
},
complete: function() {
// Code to always run after the AJAX call finishes, regardless of success or error
//console.log('AJAX request completed.');
// For example, re-enable the submit button if it was disabled
}
});
השאלה למה..