I'm using Ajax for the first time to call a php script. Unfortunately the script doesn't work. None of his instructions are executed. Here is the script where I use Ajax:
<?php
if (isset($_GET['errore'])) {
switch ($_GET['errore']) {
case 'authfailed':
echo
'<script>
$("#status").html("Credenziali Errate");
$("#status").css("color","red");
setTimeout(function(){
$("#status").html("Inserisci i dati forniti dall\'amministratore di sistema");
$("#status").css("color","black");
$.ajax({
url: "../php/redirect.php",
data: {action: "redirect_area_personale"},
type: "POST",
success: function() {}
});
}, 5000);
</script>';
break;
}
}
?>
And here is the script called:
<?php
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'redirect_area_personale':
header("Location: ../pages/area_personale.php");
die();
break;
}
}
?>
Console doesn't display any error. It could be a silly mistake but that's my first try so any help is very appreciated!