jquery autocomplete with json response

前端 未结 3 968
囚心锁ツ
囚心锁ツ 2020-12-02 16:02

im getting response in json, but this wont parse the json response. what m i doing wrong? i could\'nt find anything on doc http://docs.jquery.com/Plugins/Autocomplete

<
3条回答
  •  没有蜡笔的小新
    2020-12-02 16:42

    Try declaring the options outside the scope of $(document).ready(..)

    Ex:

    var acCbo = {
            minChars: 1,
            delay:500,
            max: 100,
            width: 400,
            dataType: 'json', // this parameter is currently unused
            extraParams: {
                format: 'json', //pass the required context to the Zend Controller,
                filtro: 'id_procsianv,id_atividade',
                chave: function(){
                    return $('#id_procsianv').val()+','+$('#id_atividade').val();
                }
            },
            queryParam: "descricao",
            parse: function(data) {
                if (data['qtde']>0){
                    data = data['Cbo'];
                    var parsed = [];
                    for (var i = 0; i < data.length; i++) {
                        parsed[parsed.length] = {
                            data: data[i],
                            value: data[i].id_cbo,
                            result: $('