Ho un modulo che utilizza Ajax per la verifica lato client. La fine del modulo è la seguente:Reindirizzamento pagina con richiesta Ajax corretta
$.ajax({
url: 'mail3.php',
type: 'POST',
data: 'contactName=' + name + '&contactEmail=' + email + '&spam=' + spam,
success: function(result) {
//console.log(result);
$('#results,#errors').remove();
$('#contactWrapper').append('<p id="results">' + result + '</p>');
$('#loading').fadeOut(500, function() {
$(this).remove();
});
}
});
EDIT: questo è il mio file mail3.php fare con gli errori:
$errors=null;
if (($name == "Name")) {
$errors = $nameError; // no name entered
}
if (($email == "E-mail address")) {
$errors .= $emailError; // no email address entered
}
if (!(preg_match($match,$email))) {
$errors .= $invalidEmailError; // checks validity of email
}
if ($spam != "10") {
$errors .= $spamError; // spam error
}
if (!($errors)) {
mail ($to, $subject, $message, $headers);
//header ("Location: thankyou.html");
echo "Your message was successfully sent!";
//instead of echoing this message, I want a page redirect to thankyou.html
} else {
echo "<p id='errors'>";
echo $errors;
echo "</p>";
}
Mi chiedevo se è possibile reindirizzare l'utente a un Grazie pagina se la richiesta Ajax ha esito positivo e non sono presenti errori. È possibile?
Grazie! Amit
duplcate di http://stackoverflow.com/questions/3430877/how-do-i-redirect-a-page-jquery –
@Andrea: Non è un duplicato perché sto cercando di reindirizzare la pagina solo se non sono presenti errori. Se sono presenti errori, voglio che scriva quegli errori. – Amit