Bonjour
Je cherche à comprendre les requêtes de type GET en AJAX
Pouvez vous m'expliquer pourquoi cette écriture ne marche pas?
Message d'erreur: Notice: Undefined index: idTheme in C:\wamp\www\jQuery\finmisenligne 7phpCss\2_test.php on line 9
niveau: débutant
Cordialement
1_test.php:
2_test.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 <!DOCTYPE html> <html lang="fr"> <body> <a href="2_test.php" class="clic_theme" data-identifiant="theme1">Theme 1</a> <script src="jquery.js"></script> <script> $(function(){ // on affecte au click des liens de classe "clic_theme" $('.clic_theme').on('click', function(){ // 1/ on récupère l'id_theme var id_theme = $(this).attr('data-identifiant'); // 2/ Envoie de donnee a la page 2_test.php $.ajax({ url : '2_test.php', // La ressource ciblée type : 'GET' // Le type de la requête HTTP. data : 'idTheme=' + id_theme; dataType : 'html' }); }); }); </script> </body> </html>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <!DOCTYPE html> <html> <head> </head> <body> <?php echo $_POST['idTheme']; ?> </body> </html>
Partager