views:

23

answers:

0
function formatar(result) {

    return result.q + ' (teste ko)';

}

    $(document).ready(function() {
        $('#nome_dominio').autocomplete("testeJson2.php", {

            //data is a string formatted in json
            parse: function(data) {

                //so, we can use JSON.parse
                var responseObject = JSON.parse(data);
                var nomeDeDominio = [];

                for(var i in responseObject) {
                    //goes on and creates an array from the parsed data.
                    nomeDeDominio.push(responseObject[i].nomeDominio)
                }

                  //now, nomeDeDominio is a very simple array. 

                  //doubts...

            },

            formatItem: function(result) {

                return formatar(result);
            }

        }).result(function(e, result) {

                    alert ('escolheu algo');
            });
    });

I can echo nomeDeDominio with the right values, but I need the plugin to grab this and use them as values and labels... what am I missing here?

Hope I can get a great soul to help me out. Near despair. MEM