Bonsoir à tous
Je suis débutant en AJAX et je cale un peu... j'ai du mal à comprendre pourquoi il ne m'affiche pas "Vous êtes bien connecté": (voir ci-dessous)
Index.php
check.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 <!doctype html> <html lang="fr"> <head> <link rel="stylesheet" href="reset.css"/> <link rel="stylesheet" href="form.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $("#testJson").submit(function(){ // On recupère le login, le pass et l'url login = $(this).find("#login").val(); pass = $(this).find("#password").val(); url = $(this).attr("action"); $.post(url,{login:login,password:pass},function(data){ if(data.erreur=="no"){ $("#testJson").fadeOut(); $("#testJson").before(data.retour); } },json); return false; }); }); </script> <title> Connexion </title> </head> <body> <div id="content"> <center> <h2> Authentification </h2> <form method="post" action="check.php" id="testJson"> <table> <tr> <td> Identifiant: </td> <td> <input type="text" class="text-input" name="login" id="login"/> </td> </tr> <tr> <td> Mot de passe: </td> <td> <input type="password" class="text-input" name="password" id="password"/> </td> </tr> <tr> <td colspan="2"> <input class="button" value="Connection" type="submit"/> </td> </tr> </table> </form> </center> </div> </body> </html>
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <?php $login = "login"; $pass = "pass"; $tab = array(); $tab["erreur"] = "no"; $tab["retour"] = "<p>Vous êtes bien connecté</p>"; echo json_encode($tab); ?>
Si quelqu'un peut m’éclaircir![]()
Partager