Bonjour

avec un select box (tri) je voudrais en créé d'autre avec la fonction suivante

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
 
$("select#tri").change(function(){
		// Post string
		var post_string = "type=" + $(this).val();
		alert(post_string);
		$("<select id='"+post_string+"' name='"+post_string+"'><option>test</option></select>").appendTo("#formtri");
		// Send the request and update sub category dropdown
		$.ajax({
			type: "POST",
			data: post_string,
			dataType: "json",
			cache: false,
			url: 'json/select2.php',
			timeout: 2000,
			error: function() {
				alert("Failed to submit");
			},
			success: function(data) { 
				// Clear all options from sub category select
				$("select#"+post_string).remove();
 
 
				// Fill sub category select
				$.each(data, function(i, j){
					var row = "<option value=\"" + j.value + "\">" + j.text + "</option>";
					$(row).appendTo("select#"+post_string);
				});
			}
		});
	});
le select box est bien créé mais les options issues du json n'y sont pas..

le json :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
$sql = mysql_query('SELECT id,intitule FROM '.$_POST['type'].' ORDER BY intitule ASC');
$json = array();
while($data = mysql_fetch_assoc($sql)){
	$json[] = array(
		'value' => $data['intitule'],
		'text' => $data['intitule']
	);
}
 
echo json_encode($json);
on dirait que le sucess de ma fonction jquery n'est pas pris en compte
Merci de votre aide