Donc mon script php renvoi bien "True" quand c'est bon et mon message d'erreur quand c'est pas ok.
Mais ça ne passe pas dans la fonction success dans mon script html contenant l'AJAX.
Côté php à la fin j'ai
echo json_encode($reponse);
Du coup ça m'affiche le résultat mais je comprends pas pourquoi ça repasse pas dans le script html avec la fonction success et error...
Voici mon script :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
$('#monForm').on('submit', function() {
$.ajax({
url: $(this).attr('action'),
type: $(this).attr('method'),
data: {
nom: $('#nom'),
prenom: $('#prenom').val(),
tel: $('#tel').val(),
email: $('#email').val()
},
dataType: 'json',
success: function(data){
//console.log(data);
if(data){
window.open('confirmation.html', '_self');
}
},
error: function(error){
console.log("Error:");
console.log(error);
}
});
return false;
}); |
Merci d'avance si vous avez une idée
Partager