Bonjour,

C'est ma première tentative de passage de variable en ajax et ça ne marche pas ! La variable retournée dans la page de traitement semble vide. Le tableau affiche les données statiques, mais ne retourne pas les données dynamiques de la bdd.

Pourriez-vous m'aider ? Voici le code :

Code html : 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
<?php
 
$Theme_aj = htmlspecialchars($_GET["ThemeID"]);
$Cat_aj =  htmlspecialchars($_GET["CatID"]);
$SousCat_aj = htmlspecialchars($_GET["SousCatID"]);
 
 ?> 
    <html>
<head>
 
<script>
function showUser(str) {
        
         var xhttp;   
        
        
    if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } 
        
        else{
                
                str == "<? echo $SousCat_aj ?>";
                
                xmlhttp = new XMLHttpRequest();
        
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET","text_ajax2.php?q="+str,true);
        xmlhttp.send();
    }
        }
 
</script>
</head>
 
<body>
 
<a href="#" onClick="showUser()">envoyer</a>
 
<div id="txtHint"><b>requete vide</b></div>
 
</body>
</html>

D'avance merci.