Block Margin Mutu for operasi edit.
2. popup error for each error logs
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="operasi">Operasi (%)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="operasi" name="operasi" required>
|
||||
<input readonly type="number" step="0.01" class="form-control" id="operasi" name="operasi" required>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@@ -97,7 +97,7 @@ $(document).ready(function() {
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
title: 'Ralat!',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
@@ -105,9 +105,31 @@ $(document).ready(function() {
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
let errorMessage = 'Error updating data';
|
||||
|
||||
try {
|
||||
let response = JSON.parse(xhr.responseText);
|
||||
|
||||
// If validation errors exist, show them
|
||||
if (response.errors) {
|
||||
let errorMessages = [];
|
||||
Object.keys(response.errors).forEach(function(key) {
|
||||
response.errors[key].forEach(function(error) {
|
||||
errorMessages.push(error);
|
||||
});
|
||||
});
|
||||
errorMessage = errorMessages.join('\n');
|
||||
} else if (response.message) {
|
||||
errorMessage = response.message;
|
||||
}
|
||||
} catch (e) {
|
||||
// If JSON parsing fails, use the raw responseText
|
||||
errorMessage = xhr.responseText || 'Unknown error occurred';
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: 'Error updating data: ' + xhr.responseText,
|
||||
title: 'Ralat!',
|
||||
text: errorMessage,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user