add option to select dynamically using jqtransform

387 views Asked by At

I am using the plugin jqtransform to dynamically add options to a select using Ajax. Here I leave my script. Could you tell me what I have to do to see my new options?

<script type="text/javascript" >
        var path = '<?php echo base_url() ?>';
        $(document).on('ready', function() {
            cargarJugadores();
            $('#equipos').change(cargarJugadores);
        });
        function cargarJugadores() {
            var codEquipo = $('#equipos').val();
            $.getJSON(path + 'traspasos/devuelveJugadoresPorId', {id: codEquipo}, function(resp) {
                console.log("->", resp);
                $('#jugadores').empty();
                $.each(resp, function(indice, valor) {
                    option = $('<option></option>', {
                        text: valor,
                        value: indice
                    });
                    $('#jugadores').append(option);
                });
            });
            $('#jugadores').jqTransSelect(true);
        }

    </script>
0

There are 0 answers