Jquery Chosen not returning value

0

How to get chosen to display search value. It is not showing the options inside the select.

HTML

<select id="habilidades" name="habilidades[]" multiple class="input col-lg-10 chosen-select margem20" required>

</select>

SCRIPT

$("#subcategoria").change(function(){

            $.post("inc_habilidades.php",
                {id:$(this).val()},
                function(valor2){
                    $("#habilidades").html(valor2)
                }
            )
        })

        $(".chosen-select").chosen();

The return of the inc_habilidades.php file, are not appearing inside the select

    
asked by anonymous 01.08.2017 / 16:01

1 answer

2

The command $.post asynchronous, you can put $(".chosen-select").chosen(); inside the function.

Example:

$("#subcategoria").change(function(){

        $.post("inc_habilidades.php",
            {id:$(this).val()},
            function(valor2){
                $("#habilidades").html(valor2)
                $(".chosen-select").chosen();
            }
        )
    })
    
01.08.2017 / 16:30