У меня есть этот код для подтверждения или выдачи ошибки в моей модальной форме. когда результат успеха не равен 1, скрипт выдаёт мне ошибку. но как я могу создать для каждого человека, если ($ row1 ....) личная ошибка, которая берется из Sweetalert в виде текста. Я sh то, где написано text:'tutto sbagliato
в подсластитель. была переменная ошибки без необходимости писать код для каждого результата. Например:
if($row1 >= 3 ){
echo json_encode(array('success' => 0));}
$ result = "число не 3"
и в тексте: из подсластителя у меня есть текст: $ result
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
$(document).ready(function() {
$('#updForm1').submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "inc/inserisci_menu.php",
data: $(this).serialize(),
success: function(response)
{
var jsonData = JSON.parse(response);
// user is logged in successfully in the back-end
// let's redirect
if (jsonData.success == "1")
{
Swal.fire({
title: 'success!',
text: 'Do you want to continue',
icon: 'success',
confirmButtonText: 'Cool',
})
}
else
{
Swal.fire({
title: 'Errore!',
text: 'tutto sbagliato',
icon: 'error',
confirmButtonText: 'Ok'
})
}
}
});
});
});
// Extract info from data-* attributes
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
// Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
var modal = $(this)
})
if($row1 >= 3 ){
echo json_encode(array('success' => 2));
}
if($row1 >= 4 ){
echo json_encode(array('success' => 3));
}
if($row1 >= 5 ){
echo json_encode(array('success' => 4));
}