I need to show an alert and stop the execution of the script when the user clicks on the accept button when he does not select any week to pay, this is the ajax function:
$('#sub').click( function() {
$("#update").submit(function(e){
var formData = new FormData(this);
e.preventDefault();
$.ajax({
url: "files/hoursToPay.php",
type: "POST",
data: formData,
contentType: false,
cache: false,
processData: false,
success: function(data){
alert("Horas pagadas");
},
error: function(data){
console.log(data)
}
});
});
});
Inside the hoursToPay script:
<?php
// Si seleccionó al menos una semana
if (isset($_POST['hours'])):
//Codigo para pagar semanas
else:
echo '<script>alert("Selecciona al menos una semana");
return false;</script>';
endif;
?>
The problem is that the javascript code that is inside the script does not work, is there any way to make it work ?, thanks.