Bonjour
J'ai un soucis avec l'utilisation de Flexbox.
Celui-ci génère bien le "select", mais lorsque je cherche à faire fonctionner l'auto-complétion ou bien à afficher la liste des "option", j'ai droit à cette erreur :
De plus, à chaque clic sur la flèche de mon "select", le script refait un appel de ma page PHP (qui s'occupe de récupérer les infos dans la BDD et d'envoyer le tout en JSON).Invalid JSON property {name} found when trying to apply resultTemplate or paging.summaryTemplate.
Please check your spelling and try again.
Voici les bouts de codes concernés :
Et le script 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 function autoComplete(id, type) { jQuery(id).flexbox('auto_complete.php?q='+type, { watermark: 'Saisissez un(e) '+type, paging: false, method: 'POST' }); }; function(event, retour) { jQuery("#valid").fade("#valid", "Fichiers ajoutés avec succès", 4000, "slow"); jQuery.post("form.php", { session: "<?php echo $session; ?>" }, function(retour){ for(var i=0 ; i<retour.length ; i++) { var id = retour[i].id; jQuery("#formTags").append("<label for='nom_"+id+"'>Nom : </label><br />"); jQuery("#formTags").append("<label for='hotel_"+id+"'>Hotel : </label><br />"); jQuery("#formTags").append("<input type='text' value='"+retour[i].nom+"' id='nom_"+id+"' name='nom_"+id+"' /><br />"); autoComplete("#formTags", "hotel"); } }, "json"); }
Et ce que dis la doc officielle :
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 <?php // q = champ ister if( !empty($_GET['q']) ) { $dsn = 'mysql:dbname=galerie;host=127.0.0.1'; $user = 'root'; $password = ''; $db = new PDO($dsn, $user, $password); $request = "SELECT id, nom AS name FROM ".$_GET['q']; /* Rꤵp곡tion de toutes les lignes d'un jeu de r괵ltats */ $query = $db->prepare($request); $query->execute(); $results = $query->fetchAll(PDO::FETCH_ASSOC); $tab = array('results' => $results); echo json_encode($tab); } ?>
J'ai fais des recherches sur le net, mais j'ai pas trouvé de solutionThe call to results.aspx is ajax, and should return a JSON string in the format shown below.
- The "id" property is a string or integer, and is the value submitted when the form is submitted (like the "value" attribute of the html <option> tag)
- The "name" property is a string or integer, and is the text displayed for each result, and when a result is selected (like the text between the html <option> open and </option> close tags)
- All of these names and values are configurable to match the format of your JSON data
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 {"results":[ {"id":1,"name":"Ant"}, {"id":2,"name":"Bear"}, {...} // more results here.. ]}
Merci d'avance !
Edit : mon JSON semble pourtant correct.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 {"results":[ {"id":"17","name":"Occidental Torremolinos"}, {"id":"28","name":"Bergerac"}, {...} // more and more ]}
Partager