Jquery Chosen not returning value

Asked

Viewed 149 times

0

How to make the Chosen display value of the search. It is not showing the options within 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 file inc_skills.php, are not appearing within the select

  • In your code is not being shown the component that #subcategory... where he is?

  • @Nayronmorais #subcategory this above. By selecting it it is passing the POST correctly to the file inc_habilidades.php, before I tested for GET.

1 answer

2


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

Example:

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.