Bonjour à tous,
Comme d'habitude, j'ai un problème d'affichage de mes données.
Sans l'ajax mes données apparaissent mais pas avec mon script. Je dois oublié ou mal faire quelque chose mais je ne trouve pas.
Je veux qu'elles apparaissent ans ma div ("hifi").
Merci d'avance.
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
   <script> 
  $(document).ready(function(){
		$("#submit").click(function(){
           var hifi = $("#hifi").val();
				$.ajax({
		url     : 'try.php',
		type    : 'POST',
		data    : {"hifi" :hifi},
		success: function(donnees) {
		      <!--alert('ok');-->
		       $('#hif').val(donnees);
		     		}
		,
		error: function(resultat)
		{
 
		}
	});
});
});</script>
  <title></title>
  </head>
  <body>
	<form action="" method="post" id="hifi" >
		Référence : <input type="text" name = "hifi" id="hifi" size="13" tabindex="2"/>
 		<input type="submit" name="tableau" id="submit" value="OK" tabindex="5" >
		 </form>
    <div id="hif""></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
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
require("shared.php");
$req = $bdd->prepare("SELECT * FROM `basehifi` WHERE `hifi` = :hifi");
$req->execute(array(':hifi'=>($_POST['hifi'])));
$nbart=$req->rowCount();
if($nbart<='0'){
echo "<table class='spp'><th class='w10'>Référence HIFI</th><th class='w15'>Option1</th><th class='w15'>Option2</th><th class='w15'>Option3</th><th class='w15'>Option4</th><th class='w30'>Désignation</th>";
echo "<tr>";
	echo '<td>'. $_POST['hifi'] .'</td><td><img src="images/croix.jpg" alt="croix" width=20 height=20/></td><td><img src="images/croix.jpg" alt="croix" width=20 height=20/></td><td><img src="images/croix.jpg" alt="croix" width=20 height=20/></td><td><img src="images/croix.jpg" alt="croix" width=20 height=20/></td><td>PAS DE CORRESPONDANCE</td>';
echo "</tr>";
echo "</table>";
}
else {
echo "<table class='spp'><th class='w10'>Référence HIFI</th><th class='w15'>Option1</th><th class='w15'>Option2</th><th class='w15'>Option3</th><th class='w15'>Option4</th><th class='w30'>Désignation</th>";
while ($donnees = $req->fetch())
{
echo "<tr>";
	echo '<td>'. $_POST['hifi'] .'</td><td>'. $donnees['opt1'] .'</td>';
  echo '<td>';
  if(!$donnees['opt2']){
  echo '<img src="images/croix.jpg" alt="croix" width=20 height=20/>';
  }else{
  echo $donnees['opt2'];
  };
  echo '</td>';
  echo '<td>';
  if(!$donnees['opt3']){
  echo '<img src="images/croix.jpg" alt="croix" width=20 height=20/>';
  }else{
  echo $donnees['opt3'];
  };
  echo '</td>';
    echo '<td>';
  if(!$donnees['opt4']){
  echo '<img src="images/croix.jpg" alt="croix" width=20 height=20/>';
  }else{
  echo $donnees['opt4'];
  };
  echo '</td>';
  echo '<td>'. $donnees['desi'] .'</td>';
echo "</tr>";
}
echo "</table>";
}
?>