Bonjour,
Je ne comprends pas ce qui cloche.
la variable libelle_service est "undefined".
La fonction lib_service renvoie bien ce qu'il faut (si je mets un alert(xhr.responseText);, je vois le bon résultat).
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 function validation_compte () { ..... libelle_service = lib_service(id_service); ..... } function lib_service (id_service) { getXhr(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { return xhr.responseText; } }; xhr.open("POST","Script/BDD/libservice.php",true); xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-15'); xhr.send("id_service=" + id_service); }
Si je mets
OU
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14function lib_service (id_service) { return 'coucou1'; getXhr(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { return xhr.responseText; } }; xhr.open("POST","Script/BDD/libservice.php",true); xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-15'); xhr.send("id_service=" + id_service); }
C'est bon aussi.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14function lib_service (id_service) { getXhr(); return 'coucou1'; xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { return xhr.responseText; } }; xhr.open("POST","Script/BDD/libservice.php",true); xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-15'); xhr.send("id_service=" + id_service); }
Si je mets
ça va pas non plus.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 if(xhr.readyState == 4 && xhr.status == 200) { return 'coucou'; }
Mais je ne vois pas pour quelle raison.








Répondre avec citation



Pas de question technique par MP !



Partager