Struggling with Autocomplete T_T
Hello,
I'm working with Zend Framework , and I'm trying to implement an autocomplete, with some Json data. It's pretty hard to find an easy tutorial.
So, this is how data are returned to me :
-
{"module":"default","controller":"inscription","action":"societelist","liste":{"669":"CERCLE SAINT PIERRE LIMOGES BASKET ELITE","2266":"SPORT PLUS CONSEIL ET ORGANISATION LIMOGES","2862":"MAIRIE DE LIMOGES","3794":"USAL RUGBY LIMOGES SASP"}}
as you can see, the data array are in the "liste" key. But these ones are unreadable by autocomplete.
-
var Liste = new Array();
$.ajax({
type: "POST",
url: "/inscription/societelist",
async: true,
dataType: "json",
data: { format: "json" }, // Aucune donnée envoyée
success: function(retour){
Liste = retour.liste;
}
});
$("input#societe").autocomplete(Liste);
What I want to do, is that when I select an option, an hidden field is setted with the id.
Strangely, when I create a little array manually like
-
var Liste = new Array();
Liste[0] = "Societe 1";
Liste[1] = "Societe 2";
Liste[2] = "Societe 3";
$("input#societe").autocomplete(Liste);
It works.
I believe that if the indexes of the array don't start by 0, it won't work...
Thanks for your help.